Dict naming, global vs local imports, etc. [was Re: *Naming Conventions*]

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Mon Jun 4 03:17:26 EDT 2007


In <1180911610.702985.215970 at q75g2000hsh.googlegroups.com>, George Sakkis
wrote:

> While we're at it, although it's not strictly a naming convention
> issue I still waste brain cycles on where to put the import statements
> that are used only once or twice in a module. Should
> (1) all imports be at the global scope at the top of the module, or
> (2) be imported in the function or method they are actually used ?
> 
> […]
> 
> Reasons for (2)
> ---------------
> - Point of import closer to point of use; easy to notice if a given
> import is not used any more after refactoring.

`pylint` reports unused imported names.  I don't follow PEP8 only if it's
not possible otherwise.  But cyclic imports are bad anyway.  :-)

And if the import is *really* expensive and only needed in some special
circumstances.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list