I want my class to have a class variable whose value is of that same class:
class XY:
Origin = XY(0,0)
def __init__(self, x, y):
self.x = x
self.y = y
however, this fails with
Origin = XY(0,0)
NameError: name 'XY' is not defined
Apparently, I can do
class XY:
...
XY.Origin = XY(0,0)
instead - is this really the right way?
Would a "metaclass" work any better for you? Perhaps something like:
I think that might give you: