Skip to content

Instantly share code, notes, and snippets.

@mitgr81
Created November 5, 2013 21:42
Show Gist options
  • Save mitgr81/7326862 to your computer and use it in GitHub Desktop.
Save mitgr81/7326862 to your computer and use it in GitHub Desktop.
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