Why property works only for objects?

Alex Martelli aleaxit at yahoo.com
Sun Mar 12 19:16:24 EST 2006


Michal Kwiatkowski <ruby at no.spam> wrote:

> Alex Martelli napisa?(a):
> >> IMHO that's not very consistent. 
> > 
> > How so? Given the lower-level semantics of descriptors (and the
> > distinction between overriding and non), are you suggesting that
> > property should not be a type but a factory function able to return
> > instances of either overriding or non-overriding types? I'm not sure how
> > that complication would make things "consistent" in your view.
> 
> Nothing in property documentation suggest that if you don't define
> __set__ method, you won't be able to set an attribute. It just states
> "Return a property attribute for new-style classes". After reading a bit
> about descriptors I've just assumed that property is a handy way to
> create (any) descriptors. Learning that it only creates overriding
> descriptors was a bit shocking. I'm not suggesting it's bad behavior,
> only that it seemed unexpected for an unaware programmer. What at first
> glance looked like a shortcut, turned out to be designed for a specific
> use case.

Yes, I see that the docs at
<http://docs.python.org/lib/built-in-funcs.html> are too curt about
exactly what it is that property returns -- no inconsistency, just
too-scarce docs.  The in-development draft at
<http://docs.python.org/dev/lib/built-in-funcs.html> is just about the
same. Why don't you try your hand at making the docs better? As
<http://www.python.org/dev/doc/> points out, *Documentation submissions
are welcome in plain text from contributors without LaTeX knowledge*.

I'd give it a try myself, but doing anything except working on the 2nd
edition of the Nutshell right now would seriously risk ending up
strangled... sigh -- once the Nutshell's 2nd ed is done and over with,
and I've recovered from it, I'll need to get around to serious
contribution to the standard Python docs!-)


Alex



More information about the Python-list mailing list