A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-November/010816.html below:

[Python-Dev] {}.first[key,value,item] and {}.pop (was Re: {}.getitem())

[Python-Dev] {}.first[key,value,item] and {}.pop (was Re: {}.getitem())Barry A. Warsaw barry@digicool.com
Thu, 30 Nov 2000 10:14:53 -0500
>>>>> "PF" == Peter Funk <pf@artcom-gmbh.de> writes:

    PF> Since [].pop() takes in optional index as parameter which
    PF> defaults to the *LAST* element, it would be better to make the
    PF> name explicit: .popfirstitem()

{}.pop() sounds like the right thing given its symmetry with [].pop().

It would have the semantics that it would remove and return a random
/item/ from the dictionary, which the implementation can make the
"first" item for convenience purposes.

It shouldn't dictate though, that {}.pop() == dict.items().pop() or
make any other guarantees about which item gets popped, because other
implementations (or indeed, other mapping-conformant objects) may use
different underlying representations that could make this inefficient.

For added symmetry, {}.pop() should take an optional argument which is
the key of the item to remove and return.

-Barry



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4