Created
October 7, 2012 16:17
-
-
Save dbarnett/3848795 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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