New submission from multun <[email protected]>:
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 <[email protected]>
<https://bugs.python.org/issue34961>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com