running a random function

Stebanoid Stebanoid at gmail.com
Thu Jun 7 13:30:09 EDT 2007


On 7    , 19:56, David Bear <david.b... at asu.edu> wrote:
> I would like to write some code that would randomly select a function from a
> list of functions and call it. I was looking in the globals names space and
> randomly selecting items that were of type function.. but I didn't see a
> way of actually running the function.
>
> Any pointers?
>
> --
> David Bear
> -- let me buy your intellectual property, I want to own your thoughts --

if you have a list of functions you can try this:

import random
import math
m[int(math.ceil(random.random()))]() #seems like Lisp code :)

but what about functions arguments?
Strange task... Very strange....




More information about the Python-list mailing list