18.12.21 13:18, [email protected] пише:
> 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.
classmethod supersedes staticmethod. It was not clearly known when they
were introduced, but now we see that there is very few use cases for
staticmethod which cannot be replaced by classmethod (actually only one
specific case). If it would be known in advance staticmethod would be
not added.
So you can use a combination of @classmethod and @property.
class Data:
@classmethod
@property
def imagesTotal(cls):
return 10
There are some issues with help() and unittest.mock. They may not work
as you expected.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/JQKITGZCCE2LM6ZJJETW4FRIZR3B3463/
Code of Conduct: http://python.org/psf/codeofconduct/