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/2009-November/093849.html below:

[Python-Dev] Retrieve an arbitrary element from asetwithoutremoving it

[Python-Dev] Retrieve an arbitrary element from asetwithoutremoving itChris Bergstresser chris at subtlety.com
Fri Nov 6 07:19:27 CET 2009
On Thu, Nov 5, 2009 at 11:43 PM, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> I read Raymond's suggestion rather as a question: why bother with a
> tedious, multi-year process, when a three-line function will achieve
> exactly the same?

   Because it doesn't achieve exactly the same.  What I want is a
sane, rational way to describe what I'm doing in the core API, so
other programmers learning the language don't spend the amount of time
I did perplexed that there was a .pop() and a .remove() and a
.discard(), but there wasn't a .pick().  I don't want to have to write
the same little helper function in every project to fill a deficiency
in the library.  I don't want to have to argue about the flaws in
solutions with race conditions, or the fact that cheap functions
become expensive functions when performed over the network, or that
there's a real value in having an atomic operation which throws a sane
exception when it fails, or how it's disturbing to my OCD core to have
an API which believes:

  if x in s:
    s.remove(x)

... is too confusing, so there should be a .discard() method, but ...

  for x in s:
    break

... is self-evident and obvious, so there's no need for a .pick().

-- Chris
More information about the Python-Dev mailing list

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