On Apr 17, 3:51 am, [EMAIL PROTECTED] wrote:
> I'm reading the docs now and I stumbled upon something:
> section "15.3 threading -- Higher-level threading interface" mensions
> a class "local", in which "... Thread-local data are data whose values
> are thread specific. ..."
>
> Does it mean, I can create global variables whose changing is thread-
> safe?
> More specific:
>
> import threading
>
> def change_i(arg):
> global k
> k.i = arg
>
> def change_j(arg):
> global k
> k.j = arg
>
> def changer():
> change_i('changed_i')
> change_j('changed_j')
>
> def run(i='', j=''):
> global k
> k = threading.local()
> k.i = i
> k.j = j
> changer()
> i = k.i
> j = k.j
> return i, j
>
> print run() == ('changed_i', 'changed_j')
>
> Is this ok?
I was too quick, "k = threading.local()" has to by outside of run(),
right?
--
http://mail.python.org/mailman/listinfo/python-list