This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tusharsadhwani
Recipients tusharsadhwani
Date 2021-08-22.06:39:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629614383.81.0.292978789456.issue44973@roundup.psfhosted.org>
In-reply-to
Content
Starting with Python3.9, `@classmethod` can be stacked on top of `@property`, but it seems that `@staticmethod` cannot.


>>> class C:
...     @classmethod
...     @property
...     def cm(cls):
...         return cls.__name__

...     @staticmethod
...     @property
...     def magic_number():
...         return 42
... 
>>> C.cm
'C'
>>> C.magic_number
<property object at 0x7f0ad3c1ea90>
>>> 


This feels like inconsistent behaviour, plus, having staticmethod properties can be useful for creating read-only class attributes, for eg:


class C:
    @staticmethod
    @property
    def FINE_STRUCTURE_CONSTANT():
        return 1 / 137


This would make it hard to accidentally modify the constant inside the class.
History
Date User Action Args
2021-08-22 06:39:43tusharsadhwanisetrecipients: + tusharsadhwani
2021-08-22 06:39:43tusharsadhwanisetmessageid: <1629614383.81.0.292978789456.issue44973@roundup.psfhosted.org>
2021-08-22 06:39:43tusharsadhwanilinkissue44973 messages
2021-08-22 06:39:43tusharsadhwanicreate