[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python threading and sharing variables

Chris Angelico wrote:

> You can be confident that a single assignment will happen atomically.
> Even if "self.cnt = i" requires multiple instructions to perform

For name binding

cnt = i

maybe, but

self.cnt = i

can execute arbitrary Python code (think __setattr__()). With threads I'd 
rather play it safe.