[Tutor] Why a global?
Alan Gauld
alan.gauld at btinternet.com
Thu Dec 28 17:15:31 CET 2006
"Carlos" <carloslara at web.de> wrote
>
> Sheesh, that solved it, guess that I got to learn OO next. Unles it
> is
> not related... :-[
The problem you had was about reassigning a name from a
module to an object, but it could have been any kind of
object - a variable, a function, another module, anything.
So really it had nothing to do with OO.
If you do:
import sys as s
s = 42
s.exit()
you will get an error because you renamed sys to s then
used s as a local varuiable, thus overwriting (and thus losing)
the module reference. You need to ensure that your names
don't collide.
Alan G
More information about the Tutor
mailing list