
Guido van Rossum wrote:
M.-A. Lemburg:
Shouldn't be hard to do... the C API for this is already in place: PyDict_Next(). I'd prefer a method .getitem(), though, which then returns a tuple (key, value).
IMO '.pickitem()' would be a better name, since many people would think, that 'getitem()' would take some kind of index as parameter. Nevertheless I think this is a nice idea, though.
Pronouncement:
It is only efficient to get the *first* item, so let's make that explicit. The method names will be:
.firstkey()
-1
.firstvalue()
-1
.firstitem()
+1 I really think that .firstitem() is both more intuitive and efficient -- .firstvalue() and .firstkey() are simply derivatives of this method or how would you define the return value of those two methods ?
Moshe will check in a patch.
Thinking aloud:
Would it be useful to also implement popkey(), popvalue(), popitem(), which would remove the first item and then return the relevant part of it?
+1 Same comment as above... .popitem() suffices.
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://www.python.org/mailman/listinfo/python-dev
-- Marc-Andre Lemburg ______________________________________________________________________ Company: http://www.egenix.com/ Consulting: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/