Created
November 5, 2013 21:42
-
-
Save mitgr81/7326862 to your computer and use it in GitHub Desktop.
This file contains 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
class Parent(object): | |
def __new__(cls, to, *args, **kwargs): | |
if hasattr(to, 'something'): | |
return object.__new__(Child) | |
return object.__new__(Parent) | |
def send(self): | |
raise RuntimeError('You must override the send method for this Parent subclass') | |
class Child(Parent): | |
def __init__(self, to, *args, **kwargs): | |
print(kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment