"from module import data; print(data)" vs "import module; print(module.data)"

Ethan Furman ethan at stoneleaf.us
Thu Feb 25 11:51:39 EST 2016

On 02/25/2016 08:20 AM, Dan Stromberg wrote:

> My intuition is telling me that "module.data; module.data.mutate()"
> would be easier to monkey patch in a way that all modules will see.
> Is that fair to say?

It is fair to say that if you need to monkey-patch a module, you should 
import the module.  :)

You should also import it before anything else does to make sure your 
change is visible to all other code.


More information about the Python-list mailing list