pop method question
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Mar 5 22:15:42 EST 2007
En Sat, 03 Mar 2007 19:55:16 -0300, Steven D'Aprano
<steve at REMOVE.THIS.cybersource.com.au> escribió:
> I personally don't see that pop has any advantage, especially since the
> most useful example
>
> while some_dict:
> do_something_with(some_dict.pop())
>
> doesn't work. Instead you have to write this:
For such constructs, one can use popitem:
while some_dict:
do_something_with(some_dict.popitem()[1])
The popitem method is older than pop. I don't like pop either.
--
Gabriel Genellina
More information about the Python-list
mailing list