How to get an item from a simple set?

Pete Forman pete.forman at
Fri Nov 26 13:34:04 CET 2004

Steven Bethard <steven.bethard at> writes:

 > So is this just one branch of a case statement?  What do you do in
 > the case that len(s) != 1?  And which one happens more often?

My s contains a set of possible values that are being refined.  I'm
printing either a single resolved value or "many" to indicate there is
still some way to go.  len(s) > 1 is not exceptional though len(s) ==
0 would be.  Over the run of the program one and many will happen
equally often.  Performance is less of an issue than clarity of the
Pete Forman                -./\.-  Disclaimer: This post is originated
WesternGeco                  -./\.-   by myself and does not represent
pete.forman at    -./\.-   opinion of Schlumberger, Baker           -./\.-   Hughes or their divisions.

More information about the Python-list mailing list