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

2010-06-17 Thread python
Are there any efficiency or style guidelines regarding the choice of import module vs. from module import name, ...? If one only needs to import a few names from a module, are there specific benefits to explictly importing these names? My understanding is that both forms of the import command

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Stephen Hansen
On 6/17/10 9:12 AM, pyt...@bdurham.com wrote: Are there any efficiency or style guidelines regarding the choice of import module vs. from module import name, ...? There are no legitimate efficiency issues. In theory, module.blah is slightly slower then blah, but that slightly is largely

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Ethan Furman
Stephen Hansen wrote: On 6/17/10 9:12 AM, pyt...@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'

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Stephen Hansen
On 6/17/10 10:01 AM, Ethan Furman wrote: Stephen Hansen wrote: On 6/17/10 9:12 AM, pyt...@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

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Ethan Furman
Stephen Hansen wrote: On 6/17/10 10:01 AM, Ethan Furman wrote: Stephen Hansen wrote: On 6/17/10 9:12 AM, pyt...@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

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Jack Diederich
On Thu, Jun 17, 2010 at 12:58 PM, Stephen Hansen me+list/pyt...@ixokai.io wrote: On 6/17/10 10:01 AM, Ethan Furman wrote: Stephen Hansen wrote: On 6/17/10 9:12 AM, pyt...@bdurham.com wrote: Now, this is all IMHO: the style guide does not define any 'guidelines' on this, except that its okay

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Ethan Furman
Jack Diederich wrote: You want to import a name that is itself a namespace; preferably a module or package and sometimes a class. Importing constants can lead to trouble. ex/ from settings import DEBUG if DEBUG: log('debug is on!') The value of the flag gets fetched at import time. If code

Re: Efficiency/style issues of import module vs. from module import name, ...

2010-06-17 Thread Stephen Hansen
On 6/17/10 10:22 AM, Jack Diederich wrote: On Thu, Jun 17, 2010 at 12:58 PM, Stephen Hansen It explicitly states later its entirely OK to import classes. It never says anything else directly, except in the example given, it shows you importing a constant. So, its giving implicit approval to