selecting a random item from a set

Martin v. Loewis martin at v.loewis.de
Tue Dec 30 18:30:43 EST 2003


Alexander Schmolck wrote:

> Is there a better way? If not, how about something like Set.randompop()?

In principle, random.choice "ought to" work. It doesn't, as it expects
the set to be indexable.

I would not like the Set type to grow random methods :-)

Regards,
Martin





More information about the Python-list mailing list