steve at holdenweb.com
Thu Jun 29 03:28:43 EDT 2006
Georg Brandl wrote:
> Nick Maclaren wrote:
>>In article <mailman.7574.1151511089.27775.python-list at python.org>,
>>"Fredrik Lundh" <fredrik at pythonware.com> writes:
>>|> identical? you only applied @property to one of the methods, and then you're
>>|> surprised that only one of the methods were turned into a property?
>>I wasn't expecting EITHER to be turned INTO a property - I was expecting
>>both methods to be the same, but one would have non-default properties
>>attached to it.
> That's another sign that property isn't intended to be used as a decorator.
> Normally, decorators wrap functions with other functions. property doesn't
> return a function but a descriptor object.
OK, I still think the docs need updating, but to explain the above as
the reason *why* property's use as a decorator is not advised. Or is it
stylistically and semantically acceptable in the case of a read-only
Would it make sense, in the single argument case, to default the doc
value to fget.__doc__ to support that use case, or should we just not
create read-only properties by using property as a decorator?
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Love me, love my blog http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list