Newbie: Why doesn't this work
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Tue Jan 1 14:37:15 EST 2008
En Tue, 01 Jan 2008 16:57:41 -0200, <petr.jakes.tpc at gmail.com> escribi�:
> Gabriel, if I understand it properly, it is necessary to define get/
> set/del/doc methods for each attribute for which I want to set the
> "property" data descriptor (which triggers get/set/del/doc function
> calls upon access to defined attribute).
Yes. Not all of them, just what you need (by example, a read-only property
doesn't require a set method; I think the get() docstring is used if no
explicit doc is provided; most of the time I don't care to define del...)
You don't "have" to define anything you don't need; moreover, you don't
have to define a property if you don't actually need it. The very first
example in the builtin functions documentation for "property" is a bad
example: if all your property does is to wrap a stored attribute, forget
about the property and use the attribute directly.
> My question is: is it possible to set the "property" for any attribute
> when I do not know what will be the name of the attribute in the
> future?
Uhm... I don't understand the question. Perhaps if you think of a concrete
case...?
--
Gabriel Genellina
More information about the Python-list
mailing list