understanding property decorator in python -


i have class defined this:

class clientapi     def __init__(self, host):        self.host = host     def foo(self, foo):       return self._foo(foo)    @property    def _foo(self):      return bind_api(             api=self,             path='/foo',             allowed_param=['foo']) 

where bind_api https://github.com/tweepy/tweepy/blob/master/tweepy/binder.py actually.. pattern in tweepy library https://github.com/tweepy/tweepy/blob/master/tweepy/api.py

how works? unable understand flow.. mean how variable foo transmitted foo() _foo()..?

also, now.. of paths api has changed.. instead of host:port/foo host:port/v1/foo there way can annotate these methods decorator..such methods have decorator has path='/foo' path=/v1/foo

so example

class clientapi     def __init__(self, host):        self.host = host     def foo(self, foo):       return self._foo(foo)     @new_api('v1')    @property    def _foo(self):      return bind_api(             api=self,             path='/foo',             allowed_param=['foo']) 

changes path '/foo' '/v1/foo'


Comments