Another dict method...
Emile van Sebille
emile at fenx.com
Sat May 19 00:30:45 EDT 2001
Yes. Can it retrieve them in sorted order?
I also see a clear method. Is there an advantage in using it over simply
reassigning to a new {} ?
--
Emile van Sebille
emile at fenx.com
---------
"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.990239607.10076.python-list at python.org...
> [Magnus Lie Hetland]
> > Anyone who sees the use of a dict.peekitem() which works
> > like dict.popitem() but doesn't actually remove an item
> > from the dictionary? Could be useful for things like
> > this (cf. earlier post about minimum of dict):
> > ...
> > Just a thought. The following seems a bit ... odd:
> >
> > k1, v1 = dict.popitem() # Get an item
> > dict[k1] = v1 # Put it back
>
> Under current CVS Python you can do
>
> k1, v1 = dict.iteritems().next()
>
>
More information about the Python-list
mailing list