Skip to content

Instantly share code, notes, and snippets.

@dbarnett
Created October 7, 2012 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbarnett/3848795 to your computer and use it in GitHub Desktop.
Save dbarnett/3848795 to your computer and use it in GitHub Desktop.
"""
Response to
http://venodesigns.net/2010/11/02/emulating-rubys-method_missing-in-python/
If you're going to enumerate each "missing method" and its args, why not just
define a stub?
"""
class Twython(object):
def __init__(self, params):
"""
Store params and junk. Ordinarily more verbose.
"""
self.params = params
def getPublicTimeline(self, *args, **kwargs):
return self._missing_method(*args, endpoint="http://...", **kwargs)
def _missing_method(self, *args, **kwargs):
# Make our API calls, return data, etc
print args, kwargs
twitter = Twython({})
twitter.getPublicTimeline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment