Last active
August 29, 2015 14:26
-
-
Save kannan4k/873b3b1e09321c92017b to your computer and use it in GitHub Desktop.
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 Foo(object): | |
inherited_classes = [] | |
fields = {} | |
@classmethod | |
def add_me(cls, subcls): | |
cls.inherited_classes.append(subcls) | |
print cls.inherited_classes | |
@classmethod | |
def add_field(cls, id_key) | |
fields[cls] = id_key | |
#Expected -> fields[SubFoo] = id_key | |
@Foo.add_me | |
class SubFoo(Foo): | |
Foo.add_field("id") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment