Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Python

source for the property function

 
Jump to:  
 
Rowland Smith
PostPosted: Tue Sep 02, 2008 1:42 pm    Post subject: source for the property function
       
Anyone know where the source code for the built-in property function
is located in a python distribution?

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

Thanks,
Rowland
 

 
Bruno Desthuilliers
PostPosted: Tue Sep 02, 2008 2:45 pm    Post subject: Re: source for the property function
       
Rowland Smith a écrit :
Quote:
Anyone know where the source code for the built-in property function

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

Quote:
is
located in a python distribution?

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

Quote:
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 python.org, 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.

HTH
 

 
Diez B. Roggisch
PostPosted: Tue Sep 02, 2008 2:49 pm    Post subject: Re: source for the property function
       
Rowland Smith schrieb:
Quote:
Anyone know where the source code for the built-in property function is
located in a python distribution?

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


Google the "descriptor protocol" for new-style classes. That explains it.

Diez
 

 
Christian Heimes
PostPosted: Tue Sep 02, 2008 3:36 pm    Post subject: Re: source for the property function
       
Rowland Smith wrote:
Quote:
Anyone know where the source code for the built-in property function is
located in a python distribution?

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

Property is not a function but a type. Properties are a common usage for
the descriptor protocol.

You can find the implementation of the property type in the file
LINK

Christian
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

UB 04 reklama opony matador gps tom tom Portal Miasteczko warminsko-mazurskie