[SciPy-dev] NumPy import problem.

Fernando Perez Fernando.Perez at colorado.edu
Fri Jan 6 17:28:04 EST 2006


Travis Oliphant wrote:

>>This is precisely why pep-328, which I recently mentioned, is going to be at 
>>some point enforced.  I've also been bitten more than once by this.
>> 
>>
> 
> This wouldn't really fix this problem, though because if $HOME is still 
> on your sys.path then the module would be picked up from there anyway, 
> right?  

Right, the problem of 'import foo' acidentally picking up some other foo from 
the current directory can still bite you.  Pep 328 helps, by requiring always 
fully qualified imports, but doesn't eliminate all possible cases.

> Regarding PEP-328, my understanding is that the -dot- notation needed 
> for sub-packages only works in Python 2.4, so we can't use it now unless 
> we drop support for Python 2.3 (or play ugly games with version 
> checking...) which I don't think we should until PEP-328 actually does 
> get enforced.

No, the only thing we should do right now is, even _inside_ of numpy, use

import numpy.this_or_that

instead of

import this_or_that

This is valid in all versions of python, and will continue to work when 
unqualified imports aren't supported anymore.  When pep 328 is enforced and 
they settle on a syntax, this will still be OK.

Cheers,

f




More information about the SciPy-Dev mailing list