[SciPy-user] How to solve name mangling ?
Fri Jun 8 08:27:58 CDT 2007
> > 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.
No, it's not lousy organization, honestly. As you can see, your
friend, and you, and me when I started, all did this - because it's
less typing, and because it is what we are used to. Learning not to do
this is something, like many good coding practices, that is not atall
obvious at first, and seems inconvenient, but as you get used to doing
it, you realize that it's The Right Way To Do It (TM). Explaining why
is hard - it's really something you've got to learn for yourself - as
a result of the kind of problems you've had here, and just by trying
to do it that way, and finding that is works well.
> from my_friends_module import *
> from array import array
If you use a lot of classes and so on from this module, you might do:
import numpy as N
import my_friends_module as MF
from my_friends_module import array as MFA
Then you'd be doing:
a = N.array([1,2])
b = MFA.array([1,2])
and it will probably be more obvious what's going on, and therefore
less error prone...
More information about the SciPy-user