Dec-02-2019, 02:32 PM
The following example illustrates the basic effect of the @property decorator
>>> >>> class Foo: ... def spam(self): ... return 100 ... >>> class Bar: ... @property ... def spam(self): ... return 100 ... >>> foo = Foo() >>> foo.spam <bound method Foo.spam of <__main__.Foo object at 0x7f7d3997b550>> >>> foo.spam() 100 >>> bar = Bar() >>> bar.spam 100 >>>Do you see the difference between classes Foo and Bar?