I am trying to figure out how the property
decorator works in Python.
So,
class Foo:
def method(self,param):
self._method(param)
@property
def _method(self): # works fine.. why... I havent defined this to accept any argument
#some logic
#even though it passes.. how do i retrieve "param" parameter passed above?
vs.:
class Foo:
def method(self,param):
self._method(param)
# no property decorator here (throws error)
def _method(self):
#some logic
If the decorator property
is removed, Python throws an error, which is fine, as I am passing an argument which is not accepted in the method. I understand that, but why doesn't _method(self)
need any more params with property
defined?
And how do I retrieve the param
value inside method
using decorator approach?