codon icon indicating copy to clipboard operation
codon copied to clipboard

Class variable scoping doesn't match python3

Open jplevyak opened this issue 1 year ago • 0 comments

class A:
    x = 2
    def __init__(self):
        self.x = self.x + 1
print(A().x)

python3 says "3" codon says:

x.py:4:9-13: error: 'A' object has no attribute 'x' ╰─ x.py:5:7-12: error: during the realization of init(self: A)

jplevyak avatar Mar 11 '23 22:03 jplevyak