[SciPy-user] How to solve name mangling ?

David Cournapeau david@ar.media.kyoto-u.ac...
Fri Jun 8 22:40:07 CDT 2007

Stef Mientki wrote:
>>     Another solution could be, but don't know if it's safe enough
>>         from my_friends_module import *
>>         # and always as the last import do my own
>>         from scipy import array
>>     Is this a good solution ? 
>> No because when you'll want to use array, which array is it really ?
> Sorry, I must be missing something here, doesn't
>    "from scipy import array"
> (as the LAST line) override any previous definition of "array" ??
Yes it does, after from scipy import array, but you only solved the 
problem of array, that is what if other names arouse ? I still don't 
understand what the problem is with doing import my_friends_module as 
MF, and use the functions as MF.foo. Using from module import *, that is 
importing everything from a module totally defeats the purpose of 
namespace (and is not specific to python; C++ namespace are exactly the 
same: doing from module import * everywhere is exactly the same than 
doing using namespace std, etc... everywhere in your header files, which 
is an horrible thing to do).


More information about the SciPy-user mailing list