Instantly share code, notes, and snippets.

# ChrisBeaumont/custom.css

Last active Jun 22, 2022
Demystifying Python Descriptors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

### ChrisBeaumont commented Jun 19, 2013

Good point -- I've made the fix. Thanks!

### szepi1991 commented Mar 12, 2015

First of all, thanks for the great article, it's informative and easy to follow! I wanted to let you know the link posted under the "UPDATE" is actually dead at this point.

Also, I can't immediately see a "natural" way to combine multiple descriptors to enforce multiple constraints (say negative and even).. am I missing something? I'm asking purely out of curiosity.

### jaimefrio commented Mar 27, 2015

The correct link seem to be this. If that doesn't work either, just go to the archives for January 2012 here and search for "descriptor".

And yes, it is indeed a great read, thanks for putting this together!

### amarlakhtakia commented Aug 31, 2017

@ChrisBeaumont i observed a typo in the following code fragment. "-1" value needs to be changed to "-100"

m = Movie('Casablanca', 97, 102, 964000, 1300000) print m.budget # calls Movie.budget.__get__(m, Movie) m.rating = 100 # calls Movie.budget.__set__(m, 100) try: m.rating = -1 # calls Movie.budget.__set__(m, -100) except ValueError: print "Woops, negative value"

### gdementen commented Oct 10, 2018

@ChrisBeaumont, @jaimefrio The link seems to be wrong again. ;-). I think the correct link is: https://mail.python.org/pipermail/python-list/2012-January/618572.html