Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:

The underlying data structure for sets doesn't lend itself to an
efficient method of random selection.  It is best for the programmer to
explictly convert to a sequence and then make the random selection (that
way the conversion cost isn't hidden). 

If you don't mind the inefficiency of an implicit conversion to a list,
you can use "random.sample(s, 1)[0]".  If only an arbitrary element is
needed, use "x=next(iter(s))" to non-destructively fetch the first element.

----------
resolution:  -> rejected
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7522>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to