running a random function

Dustan DustanGroups at gmail.com
Thu Jun 7 16:07:34 EDT 2007


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





More information about the Python-list mailing list