Skip to content

Instantly share code, notes, and snippets.

@fallingfree
Created November 13, 2012 06:41
Show Gist options
  • Save fallingfree/4064347 to your computer and use it in GitHub Desktop.
Save fallingfree/4064347 to your computer and use it in GitHub Desktop.
Cleanest way to override __init__ where an optional kwarg must be used after the super() call?
#http://stackoverflow.com/questions/5031711/python-cleanest-way-to-override-init-where-an-optional-kwarg-must-be-used
def __init__(self, *args, **kwargs):
user = kwargs.pop('user', None)
super(BaseCheckoutForm, self).__init__(*args, **kwargs)
if user is not None:
self.prefill_from_user(user)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment