[Python-Dev] {}.getitem() (was Re: PEP-0218)
Guido van Rossum
guido@python.org
Thu, 30 Nov 2000 06:10:33 -0500
> 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()
.firstvalue()
.firstitem()
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?
--Guido van Rossum (home page: http://www.python.org/~guido/)