[ static methodsby contrastare called without an instance argument unlike simple functions outside classtheir names are local to the scopes of the classes in which they are definedand they may be looked up by inheritance instance-less functions can be called through class normally in python xbut never by default in using the staticmethod built-in allows such methods to also be called through an instance in and through both class and an instance in python (that isthe first of the following works in without staticmethodbut the second does not)methods smeth( [ obj smeth( [ static methodcall through class no instance passed or expected static methodcall through instance instance not passed class methods are similarbut python automatically passes the class (not an instancein to class method' first (leftmostargumentwhether it is called through class or an instancemethods cmeth( [ obj cmeth( [ class methodcall through class becomes cmeth(methods class methodcall through instance becomes cmeth(methods in we'll also find that metaclass methods-- uniqueadvancedand technically distinct method type--behave similarly to the explicitly-declared class methods we're exploring here counting instances with static methods nowgiven these built-inshere is the static method equivalent of this section' instance-counting example--it marks the method as specialso it will never be passed an instance automaticallyclass spamnuminstances use static method for class data def __init__(self)spam numinstances + def printnuminstances()print("number of instances%sspam numinstancesprintnuminstances staticmethod(printnuminstancesusing the static method built-inour code now allows the self-less method to be called through the class or any instance of itin both python and xfrom spam_static import spam spam( spam( spam(spam printnuminstances(number of instances advanced class topics call as simple function