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
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
ins
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 1,