is this data structure build-in or I'll have to write my own class?
Jorge Vargas
jorge.vargas at gmail.com
Wed Feb 27 04:10:50 EST 2008
On Wed, Feb 20, 2008 at 7:34 PM, Carl Banks <pavlovevidence at gmail.com> wrote:
> On Feb 20, 8:12 am, "Jorge Vargas" <jorge.var... at gmail.com> wrote:
> > I need a data structure that will let me do:
> >
> > - attribute access (or index)
> > - maintain the order (for iter and print)
> > - be mutable.
> >
> > in case there isn't one. I was thinking having a base class like Bunchhttp://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308and on
>
> > top of that keeping a list of the keys and pop/push to the list when
> > adding/deleting items. I don't like this idea because I'll have to
> > keep each key twice. (in the list and in __dict__, is this the only
> > way of doing it?
>
> OrderedDict is usually the term used here for this (not to be confused
> with SortedDict, which is a mapping type with identically sorted
> keys). It's asked for pretty often but no one's stepped up to
> implement one for the standard library.
Yes, what I really nice is an OrderedDict, interesting ... maybe it
could be a nice contribution for
http://docs.python.org/lib/module-collections.html interesting I just
read the docs and it's there. I look around and those seems to be
implement on the C layer.
>
>
> Carl Banks
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list