Why my thread can't access the global data?
ddh
doudehou at gmail.com
Wed Dec 21 03:12:32 EST 2005
Thank you very much.
I am a newbie for python :-)
Antoon Pardon wrote:
>
> It has nothing to do with threads. If you assign to a name in
> a function, that name will be treated as a local variable. So
> the go_on = False in read_send will not affect the global go_on.
>
> If you want to rebind global names in a function you have to use
> the global statement. So your function would start:
>
>
> def read_send(s):
> global go_on
> s.setblocking(1)
> ...
>
> --
> Antoon Pardon
More information about the Python-list
mailing list