Importing Definitions

Skip Montanaro skip at pobox.com
Thu Sep 5 14:06:56 EDT 2013


>> You can! Any name will work, functions aren't special.
>>
>> from module1 import method1, A, B, C, D, E
>
> Better practice is to use:
>
> import module1
> print module1.A
> print module2.B
>
> and so forth since that makes it far more clear what you are doing and
> where they come from. But it's not compulsory.

Maybe I'm imagining things, but I think it's pretty common to see some
big-ass modules imported using "from module import *".  While people
may think that's expedient, I think it can often be the source of
subtle bugs.

Skip



More information about the Python-list mailing list