On classes you can create properties:
class foo():
_bar = None
@property
def bar(self):
return self._bar
#----------------------------------------------------------------------
@bar.setter
def (self, value):
""""""
self._bar = value
Which is awesome, but I was wondering if it was possible to extend @property
and setter
outside the class setting.
So in a module I could have:
_bar = None
@property
def bar():
return _bar
#----------------------------------------------------------------------
@bar.setter
def (self, value):
_bar = value
That way I can have this operation bar on the module level:
>>> print(mymodule.bar)
None
>>> mymodule.bar = "Fish"
>>> print(mymodule.bar)
Fish