appending to a list via properties

Carl Banks invalidemail at aerojockey.com
Sat Feb 11 12:22:51 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.
>
> > growing_lists = foo,qux
> > while some_condition:
> >     for (s,x) in zip(growing_list,calculate_something()):
> >         list.append(s,x)
> >
> > No I don't really recommend it.
>
> Why not?  Seems OK.  Maybe simplified to:

Well, for this simple case I guess.  If you have a lot of lists, or
you're trying to write a general multiple list appender, it would be
fine.

Carl Banks




More information about the Python-list mailing list