[Python-ideas] get method for sets?

Paul Du Bois paul.dubois at gmail.com
Thu May 17 04:19:50 CEST 2012


> | Mike Meyer writes:
> |  > def get(s):
> |  >     for x in s:
> |  >         return s

On Wed, May 16, 2012 at 5:56 PM, Cameron Simpson <cs at zip.com.au> wrote:
>  def an(s):
>    for i in s:
>      return i

Normally I'm content to lurk, but this thread has been going on for a
long time without anyone pointing out that the "for" loop idiom needs
an "else: raise KeyError" in order to act pythonically.

p



More information about the Python-ideas mailing list