How can I define a static class member with the type of this same class it is in? I intuitively tried it like this:
class A:
def __init__(self,a,b,c,d):
...
default_element = A(1,2,3,4)
Which gives the error
name 'A' is not defined
It would make the code for setting/resetting short and organized. There are workarounds such as
class A:
def __init__(self,a=1,b=2,c=3,d=4):
...
or
class A:
def __init__(self,a,b,c,d):
...
@staticmethod
def getDefault():
return A(1,2,3,4)
but I would prefer the default element if possible, so we actually have an object representing the default, instead of a method and you can only have one set of default values, while with the prefered option I could have multiple different template-objects.
I'm on Python 3.6.9.