So in Python, I have one class:
class Parent(object):
ID = None
@staticmethod
def getId():
return Parent.ID
Then I redefine the identifier in the child class, for example:
class Child(Parent):
ID = "Child Class"
Now I want to call a method getId()for a child:
ch = Child()
print ch.getId()
I would like to see "Child Class" now, but instead I get "None".
How can I achieve this in Python?
PS: I know that I can directly access ch.ID, so this may be a more theoretical question.
source
share