Lambda the Ultimate

inactiveTopic How-To Guide for Descriptors
started 6/1/2003; 5:06:44 PM - last post 6/5/2003; 4:10:48 PM
andrew cooke - How-To Guide for Descriptors  blueArrow
6/1/2003; 5:06:44 PM (reads: 1936, responses: 2)
How-To Guide for Descriptors
Learning about descriptors not only provides access to a larger toolset, it creates a deeper understanding of how Python works and an appreciation for the elegance of its design.

Python tends to tie syntax to special methods. For example, array assignment can be considered sugar for the method __setitem(...)__. Descriptors extend this to instance variables - accessing can be tied to a method on bar (which receives foo as an argument).

This is a draft, picked up from python-dev - I believe it will move into the main Python docs eventually
Posted to Python by andrew cooke on 6/1/03; 5:17:39 PM

Ehud Lamm - Re: How-To Guide for Descriptors  blueArrow
6/3/2003; 7:02:04 AM (reads: 466, responses: 0)
Similar to tied variables in Perl, right?

Adam Vandenberg - Re: How-To Guide for Descriptors  blueArrow
6/5/2003; 4:10:48 PM (reads: 399, responses: 0)
Kind of, but in spirit more like properties in Delphi or C#. In fact, calling them "descriptors" is kind of wacky, since the function for defining them is called property() anyways.