Xavier Morel <[EMAIL PROTECTED]> wrote:

> Alex Martelli wrote:
> > Carl Banks <[EMAIL PROTECTED]> 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.

If a property didn't have any side effects, there would be no reason to
define it as a property. I do fully expect x.y=z to have "side effects"
on z when y is an assignable property.

> 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.

The name 'tail' may not be ideal (for people coming from languages where
'head' is the first element and 'tail' is all the others, in
particular). But the side effect doesn't look hellish at all to me.


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to