newbe question
John Thingstad
john.thingstad at chello.no
Wed Oct 10 05:39:44 EDT 2001
I wrote the following function to use polymorphism.
def rootClassName(var):
"""Return the name of the root of a sigle inheretance class tree.
If multiple inheritance is used the leftmost class is traversed."""
if type(var) is ClassType:
cls = var
while len(cls.__bases__) != 0:
cls = cls.__bases__[0]
return cls.__name__
else:
return ""
Is there a built in function to do this ?
More information about the Python-list
mailing list