[issue34961] Global scoping when shadowing local names in class definitions

2018-10-12 Thread multun
multun added the comment: Closing, this is documented, and as such most likely intended. "A class definition is an executable statement that may use and define names. These references follow the normal rules for name resolution with an exception that unbound local variables are looked up in

[issue34961] Global scoping when shadowing local names in class definitions

2018-10-12 Thread Terry J. Reedy
Terry J. Reedy added the comment: Questions about whether basic syntax behavior is correct should be asked elsewhere, such as python-list. A proper answer requires a careful reading of the doc and a non-trivial answer. Someone on python-list should do that. Classes and scoping are known to

[issue34961] Global scoping when shadowing local names in class definitions

2018-10-12 Thread Antoine Pietri
Antoine Pietri added the comment: Tracking down the issue a bit further: a = 10 def main(): a = 42 class wtf(): print(a) class wtf2(): print(a) a = 2 main() prints: 42 10 It seems that when there is an as

[issue34961] Global scoping when shadowing local names in class definitions

2018-10-12 Thread Anton Barkovsky
Change by Anton Barkovsky : -- nosy: +anton.barkovsky ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:/

[issue34961] Global scoping when shadowing local names in class definitions

2018-10-11 Thread multun
New submission from multun : Hello, >>> a="global" >>> def func(a): ... class wtf(): ... a=a ... return wtf ... >>> func("local").a 'global' >>> def func2(a): ... class wtf(): ... b=a ... return wtf ... >>> func2("local").b 'local' Is this behavior le