running a random function

Neil Cerutti horpner at yahoo.com
Fri Jun 8 08:06:57 EDT 2007


On 2007-06-08, Stebanoid <Stebanoid at gmail.com> wrote:
> On 8    , 00:07, Dustan <DustanGro... at gmail.com> wrote:
>> On Jun 7, 1:30 pm, Neil Cerutti <horp... at yahoo.com> wrote:
>>
>> > On 2007-06-07, Stebanoid <Steban... at gmail.com> wrote:
>>
>> > > if you have a list of functions you can try this:
>>
>> > > import random
>> > > import math
>> > > m[int(math.floor(len(m)*random.random()))]()  # seems like Lisp
>>
>> > Or rather m[random.randint(0, len(m))]()
>>
>> Or rather random.choice(m)() # seems like Python
>>
>> > --
>> > Neil Cerutti
>> > Caution: Cape does not enable user to fly. --Kenner's Batman costume
>
> Sorry.... :(
> I have no experience using this module in Python, and forget
> this functions because I newer use this.
>
> Sorry for my terrible English. :P

No need to apologise. My solution above wasn't the best one
posted either!

-- 
Neil Cerutti



More information about the Python-list mailing list