workbut calls from instances failc:\codec:\python \python from spam import spam spam( spam( spam(can call functions in class in calls through instances still pass self spam printnuminstances(differs in number of instances created printnuminstances(typeerrorprintnuminstances(takes positional arguments but was given that iscalls to instance-less methods like printnuminstances made through the class fail in python but work in python on the other handcalls made through an instance fail in both pythonsbecause an instance is automatically passed to method that does not have an argument to receive itspam printnuminstances(instance printnuminstances(fails in xworks in fails in both and (unless staticif you're able to use and stick with calling self-less methods through classes onlyyou already have static method feature howeverto allow self-less methods to be called through classes in and through instances in both and xyou need to either adopt other designs or be able to somehow mark such methods as special let' look at both options in turn static method alternatives short of marking self-less method as specialyou can sometimes achieve similar results with different coding structures for exampleif you just want to call functions that access class members without an instanceperhaps the simplest idea is to use normal functions outside the classnot class methods this wayan instance isn' expected in the call the following mutation of spam py illustratesand works the same in python and xdef printnuminstances()print("number of instances created%sspam numinstancesclass spamnuminstances def __init__(self)spam numinstances spam numinstances :\codec:\python \python import spam spam spam( spam spam( spam spam(spam printnuminstances(but function may be too far removed static and class methods