[New-bugs-announce] [issue34961] Global scoping when shadowing local names in class definitions

multun report at bugs.python.org
Thu Oct 11 15:15:04 EDT 2018


New submission from multun <victor.collod at prologin.org>:

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 legit ?

Best regards,

--
Victor "multun" Collod

----------
components: Interpreter Core
files: weird_class_scope.py
messages: 327547
nosy: multun
priority: normal
severity: normal
status: open
title: Global scoping when shadowing local names in class definitions
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file47862/weird_class_scope.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34961>
_______________________________________


More information about the New-bugs-announce mailing list