Created
May 16, 2018 18:18
-
-
Save Guilouf/58142bcd30910d115a2f06dd60680470 to your computer and use it in GitHub Desktop.
"Inherit" class attributes to instance attributes
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 Params: | |
def __init__(self): | |
self.attr1 = self.attr1 | |
@classmethod | |
def ret_attr1(cls): | |
return cls.attr1 | |
Params.attr1 = "yuhuhu" | |
p2 = Params() | |
Params.attr1 = "gnegne" | |
p2attr = p2.ret_attr1() # gnegne | |
p2attr_inst = p2.attr1 # yuhuhu | |
debug = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment