New submission from jennydaman <jdmzh+pyt...@protonmail.com>:

# Example

Consider these three examples, which are theoretically identical

```
a = 4

class A:
    a = a

print(A.a)

def createB(b):
    class B:
        z = b
    print(B.z)
    
createB(5)

def createD(D):
    class D:
        d = d
    print(D.d)
    
createD(6)
```

## Expected Output

```
4
5
6
```

## Actual Output

```
4
5
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in createD
  File "<stdin>", line 3, in D
NameError: name 'd' is not defined
```

----------
components: Interpreter Core
messages: 387987
nosy: jennydaman
priority: normal
severity: normal
status: open
title: Assigning function parameter to class attribute by the same name
type: behavior
versions: Python 3.10, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43380>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to