appending to a list via properties

Xavier Morel xavier.morel at masklinn.net
Sat Feb 11 19:10:08 EST 2006


Alex Martelli wrote:
> Carl Banks <invalidemail at aerojockey.com> wrote:
>    ...
>>>     class better_list (list):
>>>         tail = property(None, list.append)
>> This is an impressive, spiffy little class.
> 
> Yes, nice use of property.
> 
> Alex

I don't know, I usually see people considering that properties are 
"cool" as long as they don't have side effects, as long as they're 
virtual members.

The tail property doesn't behave like member data at all, the semantics 
are strange, counter-intuitive (tail would usually be the end of the 
list, either [-1] or [1:], in this case it's some magic position at the 
end of the list). And it has one hell of a side effect.



More information about the Python-list mailing list