[New-bugs-announce] [issue39626] random choice to delegate to sample on sets

Ilya Kamenshchikov report at bugs.python.org
Thu Feb 13 07:59:45 EST 2020


New submission from Ilya Kamenshchikov <ikamenshchikov at gmail.com>:

In a few of my projects I had this (minor) pain of having to remember which collections of elements are sets and which are [list, tuple]. It causes me to double check and have random.sample(my_set, 1)[0] in many places. 

To me this is not how I think and causes friction: conceptually, I know something is a collection and I want 1 random choice from it. Having to differentiate on sequences vs sets makes my code uglier :(

This issue is similar to https://bugs.python.org/issue37708.

----------
components: Library (Lib)
messages: 361954
nosy: Ilya Kamenshchikov
priority: normal
severity: normal
status: open
title: random choice to delegate to sample on sets

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39626>
_______________________________________


More information about the New-bugs-announce mailing list