All of the tutorials I see online show how to create classes with __init__
constructor methods so one can declare objects of that type, or instances of that class.<
You could use a classmethod
or staticmethod
class Paul(object):
elems = []
@classmethod
def addelem(cls, e):
cls.elems.append(e)
@staticmethod
def addelem2(e):
Paul.elems.append(e)
Paul.addelem(1)
Paul.addelem2(2)
print(Paul.elems)
classmethod
has advantage that it would work with sub classes, if you really wanted that functionality.
module is certainly best though.