and python passes the lowest classsubto the class method all is well in this case-since sub' redefinition of the method calls the spam superclass' version explicitlythe superclass method in spam receives its own class in its first argument but watch what happens for an object that inherits the class method verbatimz other( printnuminstances(number of instances call from lower sub' instance this last call here passes other to spam' class method this works in this example because fetching the counter finds it in spam by inheritance if this method tried to assign to the passed class' datathoughit would update othernot spamin this specific casespam is probably better off hardcoding its own class name to update its data if it means to count instances of all its subclasses toorather than relying on the passed-in class argument counting instances per class with class methods in factbecause class methods always receive the lowest class in an instance' treestatic methods and explicit class names may be better solution for processing data local to class class methods may be better suited to processing data that may differ for each class in hierarchy code that needs to manage per-class instance countersfor examplemight be best off leveraging class methods in the followingthe top-level superclass uses class method to manage state information that varies for and is stored on each class in the tree-similar in spirit to the way instance methods manage state information that varies per class instanceclass spamnuminstances def count(cls)cls numinstances + def __init__(self)self count(count classmethod(countclass sub(spam)numinstances def __init__(self)spam __init__(selfclass other(spam)numinstances per-class instance counters cls is lowest class above instance passes self __class__ to count redefines __init__ inherits __init__ from spam_class import spamsubother spam( sub()sub(static and class methods