On Fri, 10 Aug 2018 08:15:09 +0200, Karsten Hilbert wrote:

> On Fri, Aug 10, 2018 at 12:24:25AM +0800, xuanwu348 wrote:
> 
>> Yes, move the code from positionA(can run normally) to
>> positionB(exception with name undefined) I find this content
>> "https://docs.python.org/3.3/tutorial/classes.html#python-scopes-and-
namespaces"
>> But I still don't undewrstand the differenct of  scopes-and-namespaces
>> between positionA and positionB,
>>
>> I think the variable "aLock" at these positionA or  positionB are all
>> global.
> 
> When something goes wrong in an unexpected way: test your assumptions
> ;-)



xuanwu348's assumptions are correct. aLock is a global, in both 
positions. The problem is not the scope of the variable, but whether or 
not the variable is assigned to or not.




-- 
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to