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.
try
>>> import a
>>> a.blah
>>> a.go()
>>> a.blah
or
rewrite a.py like this
blah = [ None ]
def go():
global blah
blah[0] = 5 # and not blah=[5]
then
>>> from a import *
>>> blah
>>> go()
>>> blah
will work as expected
in case 1 ( import a )
blah in a.py and a.blah in python interpr
abcd a écrit :
> 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 doe
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,
-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,