From Python 3.9 to 3.11, you could combine @classmethod and @property. However, this is now deprecated.
I found this thread: https://stackoverflow.com/questions/1697501/staticmethod-with-property
Which outlines a few possible solutions.
For example this: https://stackoverflow.com/a/76453871/12834165
class staticproperty(property):
def __get__(self, owner_self, owner_cls):
return self.fget()
class classproperty(property):
def __get__(self, owner_self, owner_cls):
return self.fget(owner_cls)
And these work fine. However, I've not been able to implement typing in a way which MyPy accepts.
I'll happily accept alternative solutions as well.
Any help much appreciated ๐
Stack Overflow
I want
Stats.singleton.twitter_count += 1
and I thought I could do
class Stats:
singleton_object = None
@property
@staticmethod
def singleton():
if Stats.singleton_objec...
