Properties couldn't work with static methods as they need to access the instance or its type. And properties are not class-properties by design, because you may want to access directly to the fields of the property object.
But you can define your own descriptor type to make a kind of class-property (read-only). Le mer. 25 août 2021 à 01:56, Henry Harutyunyan <henryharutyun...@gmail.com> a écrit : > > Currently Python does not support using `@staticmethod` decorator along with > `@property` decorator. > I think that the it currently works is a bit misleading since it will not > give an error, but gives the following outcome. > > ``` > class Foo: > @staticmethod > @property > def bar(): > return "1" > ``` > > ``` > class Foo: > @property > @staticmethod > def bar(): > return "1" > ``` > > In wither of the cases the outcome is the following > > ``` > Foo.bar > >>> <property at 0x112dbaf40> > > a = Foo() > a.bar > >>> <property at 0x112dbaf40> > ``` > > Is there any particular reason for this? Any don't we make it work? > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/M45PDOVAKJPFI55JUM3QREW3OYMW7NF5/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- Antoine Rozo _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3RMJ6YS4KOTT5OZGBKA5D5JWEEVCNOAH/ Code of Conduct: http://python.org/psf/codeofconduct/