On Sun, Dec 19, 2021 at 3:31 AM <me@chenjt.com> wrote:
In the following situations:
class Data(object): @staticmethod @property def imagesTotal(): return 10
print(Data.imagesTotal)
The "print(Data.imagesTotal)" can't print "10", it print "<property object at 0x...>".
It might be a good idea to use "@staticproperty" to solve this problem. "@staticproperty" is a decorators, it mix the @staticmethod and @property. Then the static property has getter and setter.
I'm not sure that this is actually possible the way you're doing it. The descriptor protocol (which is what makes properties work) won't apply when you're looking up statically. Your best bet, if you really need this sort of thing, would probably be to make a metaclass. But I can't advise further without a good use-case (and the example you've shown above looks extremely unpythonic). ChrisA