Another dict method...

Emile van Sebille emile at fenx.com
Sat May 19 12:29:27 EDT 2001


Sorry.  My confusion.  I sometimes use bsddb.btopen like a persistent dict,
and it's .next does return in sorted order, so I transferred the thinking to
what dict.next might do.  Looking closer, I see that not even
bsddb.hashopen.next returns keys in sorted order.

I'll just remember that next means another and doesn't imply ordering.
<wink>

then-why-not-use-prior-ly y'rs

--

Emile van Sebille
emile at fenx.com

---------
"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.990250527.29319.python-list at python.org...
> [Emile van Sebille, about the 2.2 dict.iteritems() iterator]
> > Yes.  Can it retrieve them in sorted order?
>
> No.  The order of retrieval is undefined.  It's not magic, it's fast
<wink>.
> The only sort gimmick of any kind in the language is list.sort().
>
> > I also see a clear method.  Is there an advantage in using it over
simply
> > reassigning to a new {} ?
>
> dict.clear() clears the dict in-place, without creating a new object.
> Whether that's what you want depends on whether you want aliases (other
ways
> of getting to the object besides via the name "dict") to see the effect of
> the clear too.
>
>
>





More information about the Python-list mailing list