[Python-ideas] random.choice on non-sequence
p.f.moore at gmail.com
Wed Apr 13 04:32:47 EDT 2016
On 13 April 2016 at 06:29, Joao S. O. Bueno <jsbueno at python.org.br> wrote:
> Maybe, instead of all of this, since as put by others, hardly there would be a
> "one size fits all" - the nice thing to have would be a "choice" or
> "randompop" method for sets.
Given that your choice method for sets would be little more than
value = random.choice(tuple(s))
it seems like it's probably overkill to build it into Python -
particularly as doing so restricts the implementation to Python 3.6+
whereas writing it out by hand works for any version. It also makes
the complexity of the operation explicit, which is a good thing.
More information about the Python-ideas