Oct-12-2020, 02:24 PM
use @property decorator
class Foo: @property def size(self): return 42 foo = Foo() print(foo.size) foo.size = 32output
42 Traceback (most recent call last): File "/home/boyan/sandbox2/forum.py", line 34, in <module> foo.size = 32 AttributeError: can't set attribute
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs