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 cryvate
Recipients Paul Pinterits, cryvate, docs@python
Date 2017-10-09.15:50:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507564239.8.0.213398074469.issue31735@psf.upfronthosting.co.za>
In-reply-to
Content
You get what you should get: when you print obj.d, Obj.d, you will get:

<property object at 0xDEADBEEF>

which is exactly what you expect:
- in the first case, you assigned a property object to the dictionary at obj.__dict__, so that's what you get back when you run obj.d.
- you defined a property on a class called d, and you get it when you run Obj.d

If you run print(Obj().d) you will get a TypeError: your lambda should read:

lambda self: print('called')

Properties should be added to the class not the instance, see https://stackoverflow.com/questions/1325673/how-to-add-property-to-a-class-dynamically and https://eev.ee/blog/2012/05/23/python-faq-descriptors/
History
Date User Action Args
2017-10-09 15:50:39cryvatesetrecipients: + cryvate, docs@python, Paul Pinterits
2017-10-09 15:50:39cryvatesetmessageid: <1507564239.8.0.213398074469.issue31735@psf.upfronthosting.co.za>
2017-10-09 15:50:39cryvatelinkissue31735 messages
2017-10-09 15:50:39cryvatecreate