whether they are called through an instance or class by contrastin python we are required to pass an instance to method only if the method expects one--methods that do not include an instance argument can be called through the class without passing an instance that is allows simple functions in classas long as they do not expect and are not passed an instance argument the net effect is thatin python xwe must always declare method as static in order to call it without an instancewhether it is called through class or an instance in python xwe need not declare such methods as static if they will be called through class onlybut we must do so in order to call them through an instance to illustratesuppose we want to use class attributes to count how many instances are generated from class the following filespam pymakes first attempt--its class has counter stored as class attributea constructor that bumps up the counter by one each time new instance is createdand method that displays the counter' value rememberclass attributes are shared by all instances thereforestoring the counter in the class object itself ensures that it effectively spans all instancesclass spamnuminstances def __init__(self)spam numinstances spam numinstances def printnuminstances()print("number of instances created%sspam numinstancesthe printnuminstances method is designed to process class datanot instance data-it' about all the instancesnot any one in particular because of thatwe want to be able to call it without having to pass an instance indeedwe don' want to make an instance to fetch the number of instancesbecause this would change the number of instances we're trying to fetchin other wordswe want self-less "staticmethod whether this code' printnuminstances works or notthoughdepends on which python you useand which way you call the method--through the class or through an instance in xcalls to self-less method function through both the class and instances fail (as usuali've omitted some error text here for space) :\codec:\python \python from spam import spam spam( spam( spam(cannot call unbound class methods in methods expect self object by default spam printnuminstances(typeerrorunbound method printnuminstances(must be called with spam instance as first argument (got nothing insteada printnuminstances(typeerrorprintnuminstances(takes no arguments ( giventhe problem here is that unbound instance methods aren' exactly the same as simple functions in even though there are no arguments in the def headerthe method advanced class topics