[Python-Dev] Retrieve an arbitrary element from asetwithoutremoving it
Chris 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