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-October/093349.html below:

[Python-Dev] Retrieve an arbitrary element from a set without removing it

[Python-Dev] Retrieve an arbitrary element from a set without removing it [Python-Dev] Retrieve an arbitrary element from a set without removing itScott David Daniels Scott.Daniels at Acm.Org
Mon Oct 26 07:14:06 CET 2009
John Arbash Meinel wrote:
> res = heads(node1, node2)
> if len(res) == 1:
>   # What is the 'obvious' way to get the node out?
> 
> I posit that there *isn't* an obvious way to get the single item out of
> a 1-entry frozenset.
> 
> for x in res: break
> list(res)[0]
> set(res).pop()
> iter(res).next()
> [x for x in res][0]
> x, = res   # I didn't think of this one before recently
> 
> Are all answers, but none of them I would consider *obvious*. 
And from my SQL-hacking experience:

     x = min(s)

--Scott David Daniels
Scott.Daniels at Acm.Org

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