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 int
On May 14, 3:24 pm, 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?
x = next(iter(s))
or you can suppl
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
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 Pyth
On May 14, 11:52 pm, Chris Rebert wrote:
> On Fri, May 14, 2010 at 11:23 PM, Carl Banks wrote:
> > On May 14, 9:39 am, Terry Reedy 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)
>
> >> >
On Fri, May 14, 2010 at 11:23 PM, Carl Banks wrote:
> On May 14, 9:39 am, Terry Reedy 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'
On Sat, May 15, 2010 at 4:23 PM, Carl Banks 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? I can't think of
On Sat, May 15, 2010 at 11:53 AM, Carl Banks wrote:
> On May 14, 9:39 am, Terry Reedy 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 (
On May 14, 9:39 am, Terry Reedy 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 variable.
>
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 el
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?
Thanks.
--
View this message in context:
http://old.nabble.com/an-element
11 matches
Mail list logo