Efficiency/style issues of import <module> vs. from <module> import <name>, ...

Ethan Furman ethan at stoneleaf.us
Thu Jun 17 13:01:56 EDT 2010


Stephen Hansen wrote:
> On 6/17/10 9:12 AM, python at bdurham.com wrote:
> 
> Now, this is all IMHO: the style guide does not define any 'guidelines'
> on this, except that its okay to use "from ... import ..." to pull in
> classes and (implicitly) constants, and despite how the rules say 'one
> module per line' its OK to pull in more then one name -from- a module at
> once.

What do you mean by "(implicitly) constants"?


>> My understanding is that both forms of the import command require
>> the entire module to be processed.
> 
> Yes.
> 
> "from <module> import <name>" is just a shortcut for:
> 
> import <module>
> <name> = <module>.<name>


There should also be a third line:
   del <module>

~Ethan~



More information about the Python-list mailing list