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 randolf.scholz
Recipients AlexWaygood, corona10, randolf.scholz, terry.reedy, wim.glenn
Date 2021-10-10.10:37:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1633862256.9.0.00436901792346.issue45356@roundup.psfhosted.org>
In-reply-to
Content
If fact, in the current state it seem that it is impossible to implement real class-properties, for a simple reason: 

descriptor.__set__ is only called when setting the attribute of an instance, but not of a class!!



```python
import math

class TrigConst: 
    const = math.pi
    def __get__(self, obj, objtype=None):
        print("__get__ called")
        return self.const
    
    def __set__(self, obj, value):
        print("__set__ called")
        self.const = value
        

class Trig:
    const = TrigConst()              # Descriptor instance
```

```python
Trig().const             # calls TrigConst.__get__
Trig().const = math.tau  # calls TrigConst.__set__
Trig.const               # calls TrigConst.__get__
Trig.const = math.pi     # overwrites TrigConst attribute with float.
```
History
Date User Action Args
2021-10-10 10:37:36randolf.scholzsetrecipients: + randolf.scholz, terry.reedy, wim.glenn, corona10, AlexWaygood
2021-10-10 10:37:36randolf.scholzsetmessageid: <1633862256.9.0.00436901792346.issue45356@roundup.psfhosted.org>
2021-10-10 10:37:36randolf.scholzlinkissue45356 messages
2021-10-10 10:37:36randolf.scholzcreate