Created
September 4, 2014 14:24
-
-
Save jvorcak/108314398eae466f384d to your computer and use it in GitHub Desktop.
Automatically set attributes in a class
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 User(object): | |
def __init__(self, **kwargs): | |
self.name = None | |
self.__dict__.update(kwargs) | |
u = User(name="Jan") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment