On Sun, 16 May 2010 21:53:21 -0700, Carl Banks wrote:
I've never had to do it (at least not in any situations where I had any
reluctance to call list on it), but it seems like a fairly bad
limitation. Random element from a set is such a natural idea.
There was a long discussion on the
Carl Banks wrote:
[...]
Random element from a set is such a natural idea.
Even if we were to modify the set type at the C level to support it, I
can't think of an easy way to get a random element without selection
bias. For instance, if you start from a random hash code, some
elements are
On May 14, 3:24 pm, gerardob gberbeg...@gmail.com wrote:
Hello, let S be a python set which is not empty
(http://docs.python.org/library/sets.html)
i would like to obtain one element (anyone, it doesn't matter which one) and
assign it to a variable.
How can i do this?
x = next(iter(s))
or
On 5/17/2010 12:53 AM, Carl Banks wrote:
Even if we were to modify the set type at the C level to support it, I
can't think of an easy way to get a random element without selection
bias.
At the C level, a (hashed) set is a list with empty slots. So the C
function would have to pick random
On May 14, 11:52 pm, Chris Rebert c...@rebertia.com wrote:
On Fri, May 14, 2010 at 11:23 PM, Carl Banks pavlovevide...@gmail.com wrote:
On May 14, 9:39 am, Terry Reedy tjre...@udel.edu wrote:
On 5/14/2010 11:24 AM, gerardob wrote:
Hello, let S be a python set which is not empty
On May 14, 9:39 am, Terry Reedy tjre...@udel.edu wrote:
On 5/14/2010 11:24 AM, gerardob wrote:
Hello, let S be a python set which is not empty
(http://docs.python.org/library/sets.html)
i would like to obtain one element (anyone, it doesn't matter which one) and
assign it to a
On Sat, May 15, 2010 at 11:53 AM, Carl Banks pavlovevide...@gmail.comwrote:
On May 14, 9:39 am, Terry Reedy tjre...@udel.edu wrote:
On 5/14/2010 11:24 AM, gerardob wrote:
Hello, let S be a python set which is not empty
(http://docs.python.org/library/sets.html)
i would like to
On Sat, May 15, 2010 at 4:23 PM, Carl Banks pavlovevide...@gmail.com wrote:
Which brings up an interesting question: how do you get a random
element from a set?
random.choice(list(s))
is the most straightforward way and will work a lot of the time, but
how would you avoid creating the list?
On Fri, May 14, 2010 at 11:23 PM, Carl Banks pavlovevide...@gmail.com wrote:
On May 14, 9:39 am, Terry Reedy tjre...@udel.edu wrote:
On 5/14/2010 11:24 AM, gerardob wrote:
Hello, let S be a python set which is not empty
(http://docs.python.org/library/sets.html)
i would like to obtain one
On 5/14/2010 11:24 AM, gerardob wrote:
Hello, let S be a python set which is not empty
(http://docs.python.org/library/sets.html)
i would like to obtain one element (anyone, it doesn't matter which one) and
assign it to a variable.
How can i do this?
Depends on whether or not you want the
10 matches
Mail list logo