Make variable global
Thinker
thinker at branda.to
Wed Mar 21 16:31:26 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
abcd wrote:
> I have a file, "a.py"
>
> blah = None def go(): global blah blah = 5
>
>> From the python interpreter I try....
>
>>>> from a import * blah go() blah
>>>>
>
> ...i was hoping to see "5" get printed out the second time I
> displayed blah, but it doesn't. Now, if I type this same code
> directly into the python interpreter it works as i was hoping.
> what i am missing?
>
> thanks
>
"import" imports bindings between symbols and objects into
the module from another one. When you call a function in another
module, it changes global space of module where it is defined.
The global space of the module, where caller is in, is kept from touched
except accessing through module names.
- --
Thinker Li - thinker at branda.to thinker.li at gmail.com
http://heaven.branda.to/~thinker/GinGin_CGI.py
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGAZYd1LDUVnWfY8gRAsdNAJ9niVqdGz1aG0NUzN+Ggmk+vnqZSgCfQB9s
SBuV/fWo8lqAytQP/QXQPXE=
=1BiL
-----END PGP SIGNATURE-----
More information about the Python-list
mailing list