# Python @property decorator
class Foo:
def __init__(self, my_word):
self._word = my_word
@property
def word(self):
return self._word
# word() is now a property instead of a method
print(Foo('ok').word) # ok
class Bar:
def __init__(self, my_word):
self._word = my_word
def word(self):
return self._word
print(Bar('ok').word()) # ok # word() is a method