[SciPy-user] How to solve name mangling ?

Stef Mientki S.Mientki@ru...
Fri Jun 8 07:06:12 CDT 2007



Matthew Brett wrote:
> Hi,
>
>   
>> and now I forget just 1 N, and the program seems to work correctly ...
>>     
>
> I think what we're all saying is:
>
> If you start in matlab - for example - it seems like a good idea to do:
>
> from numpy import *
>
> That's how I started.
>
> Gradually, writing code, you begin to realize that it is just much,
> much better - for clarity, and for namespace safety, to do
>
> import numpy as N
>
> Of course, if you do that, if you forget an N., you get a syntax error.
>   
well I don't ;-)
But that might have to do with my lousy organization.

Here's what I have right now,
from a friend I got a library,
with the message,
add this line at the top of your code,
and you can use everthing in the library:

    from my_friends_module import *

In my friends module there is the following code

    from  array  import  array

Now I get my N-less "array".
So I probably shouldn't have followed my friends advice,
and I should just have written

    import my_friends_module

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 ?

thanks,
Stef Mientki


Kamer van Koophandel - handelsregister 41055629  / Netherlands Chamber of Commerce - trade register 41055629




More information about the SciPy-user mailing list