Python : Resource injection