[issue46776] RecursionError when using property() inside classes

2022-02-17 Thread Steven D'Aprano
Steven D'Aprano added the comment: Maybe you expected to do this: class C: def __init__(self): self._value = 999 @property def bar(self): return self._value obj = C() obj.bar # returns 999 -- ___ Python tracker

[issue46776] RecursionError when using property() inside classes

2022-02-17 Thread Steven D'Aprano
Steven D'Aprano added the comment: This is not a bug, Python is working correctly here. The interpreter is doing exactly what you told it to do, and then raising a RecursionError before you can crash the system. You have a property instance.bar which returns instance.bar, which returns

[issue46776] RecursionError when using property() inside classes

2022-02-17 Thread chen-y0y0
New submission from chen-y0y0 : A simple class definition: class Foo: bar = property(lambda self: self.bar) And get the value of Foo.bar, it returns correctly, . And get the value of Foo().bar, it raises RecursionError: Traceback (most recent call last): File "", line 1, in File "", line