Redundant importing of modules

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Tue Dec 21 03:30:00 EST 2010


On 21 déc, 03:03, Steve Holden <st... at holdenweb.com> wrote:
> On 12/20/2010 8:36 PM, Jshgwave wrote:>
> > When writing a function that uses a module such as NumPy, it is tempting
> > to include the statement "import numpy" or "import numpy as np" in the
> > definition of the function, in case the  function is used in a script
> > that hasn't already imported NumPy.

(answering the OP - post didn't show off here on c.l.py):

This is actually totally useless. The global namespace of a function
is the namespace of the module in which it has been defined, not the
namespace of the module where the function is called.





More information about the Python-list mailing list