Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

snlkapil skapil

🎯
Focusing
View GitHub Profile
@skapil
skapil / callable.py
Last active Apr 17, 2018 — forked from durden/callable.py
Clever way to use Python __call__ and __getattr__ to create web APIs that can map directly (dynamically) to actual API
View callable.py
class MyCallable(object):
def __init__(self, urlparts, callable):
self.urlparts = urlparts
self.callable = callable
def __call__(self, **kwargs):
print kwargs
print self.urlparts
def __getattr__(self, name):
# Return a callable object of this same type so that you can just keep
# chaining together calls and just adding that missing attribute to the
You can’t perform that action at this time.