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 Benjamin Wohlwend
Recipients Benjamin Wohlwend, docs@python
Date 2017-09-13.08:38:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1505291907.9.0.809761592922.issue31441@psf.upfronthosting.co.za>
In-reply-to
Content
The first descriptor example in the descriptor docs (https://docs.python.org/3/howto/descriptor.html#descriptor-example) stores the value on the descriptor instance, which is shared among all MyClass instances. This leads to surprising (and arguably buggy from a user perspective) behaviour:

    m1, m2 = MyClass(), MyClass()
    m1.x = 5
    m2.x = 10
    print(m1.x, m2.x)
    >>> 10 10

I'm not sure how this could be fixed without making the example much more complicated (e.g. by introducing a "values" weakref dictionary on the descriptor instance). 

Maybe pointing this behaviour out in the docs could be enough, although I don't see any useful use case for a class that has this behaviour.
History
Date User Action Args
2017-09-13 08:38:27Benjamin Wohlwendsetrecipients: + Benjamin Wohlwend, docs@python
2017-09-13 08:38:27Benjamin Wohlwendsetmessageid: <1505291907.9.0.809761592922.issue31441@psf.upfronthosting.co.za>
2017-09-13 08:38:27Benjamin Wohlwendlinkissue31441 messages
2017-09-13 08:38:27Benjamin Wohlwendcreate