I'm new to python and going through someone's code to see and how it works. I've come across something I don't really understand. There is an API class and in it are what looks like class variables (?) that look like this:
class API(object):
...
ping = bind_api(
path='/user/ping',
allowed_param=['lat', 'lon'],
method='POST',
)
...
Which looks like it calls a function in another file called binder, which looks like this
def bind_api(**config):
class APIMethod(object):
path = config['path']
allowed_param = config.get('allowed_param', [])
......
I really don't get what is going on? Is this a class variable? What gets assigned to 'ping'? How do I access it?
I'm trying to write a class that uses this library, and I have something like this:
import api
class ApiTest():
def Test():
testApi = api.API()
print "Ping ",dir(testApi.ping)
print testApi.ping
But neither of those print statements really give me more insight into what is happening, or what the 'ping' variable holds, or what I'm supposed to do with it (or the other variables in the class that are doing the same thing)
bind_apihas no return statement.