source for the property function

Bruno Desthuilliers bdesth.quelquechose at
Tue Sep 2 18:45:35 CEST 2008

Rowland Smith a écrit :
> Anyone know where the source code for the built-in property function

Actually, it's a class, not a function.

> is 
> located in a python distribution?

property being a builtin type, you should find it somewhere in the 
CPython's C source AFAICT.

> I would like to see how it works - mainly, how does it know which class 
> it is being called from?

No need to look at the source for this - it's just an application of the 
descriptor protocol. Look up the doc on, or google for python 
descriptor protocol. FWIW, it's the same protocol that is used for 
turning functions into methods, and writing your own custom descriptors 
is trivial.


More information about the Python-list mailing list