Created
November 13, 2012 06:41
-
-
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?
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
#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