Re: running a random function

2007-06-08 Thread Neil Cerutti
On 2007-06-08, Stebanoid <[EMAIL PROTECTED]> wrote: > On 8, 00:07, Dustan <[EMAIL PROTECTED]> wrote: >> On Jun 7, 1:30 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> >> > On 2007-06-07, Stebanoid <[EMAIL PROTECTED]> wrote: >> >> > > if you have a list of functions you can try this: >> >> > > im

Re: running a random function

2007-06-08 Thread Stebanoid
On 8, 00:07, Dustan <[EMAIL PROTECTED]> wrote: > On Jun 7, 1:30 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > > > On 2007-06-07, Stebanoid <[EMAIL PROTECTED]> wrote: > > > > if you have a list of functions you can try this: > > > > import random > > > import math > > > m[int(math.floor(len(m)*r

Re: running a random function

2007-06-07 Thread Neil Cerutti
On 2007-06-07, Dustan <[EMAIL PROTECTED]> wrote: > On Jun 7, 1:30 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> On 2007-06-07, Stebanoid <[EMAIL PROTECTED]> wrote: >> >> > if you have a list of functions you can try this: >> >> > import random >> > import math >> > m[int(math.floor(len(m)*random.r

Re: running a random function

2007-06-07 Thread Dustan
On Jun 7, 1:30 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-06-07, Stebanoid <[EMAIL PROTECTED]> 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.ran

Re: running a random function

2007-06-07 Thread Neil Cerutti
On 2007-06-07, Stebanoid <[EMAIL PROTECTED]> 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))]() -- Neil Cerutti Caution: Cape does not enable user to

Re: running a random function

2007-06-07 Thread Stebanoid
On 7, 19:56, David Bear <[EMAIL PROTECTED]> 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 act

Re: running a random function

2007-06-07 Thread Stebanoid
On 7, 19:56, David Bear <[EMAIL PROTECTED]> 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 act

Re: running a random function

2007-06-07 Thread Roberto Bonvallet
On 7 jun, 11:56, David Bear <[EMAIL PROTECTED]> 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 act

Re: running a random function

2007-06-07 Thread Dustan
On Jun 7, 10:56 am, David Bear <[EMAIL PROTECTED]> 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.. Careful!!! You don't want t

Re: running a random function

2007-06-07 Thread Matimus
How are you making the list of functions? Something like this: [code] fs = [] for k,f in globals(): if callable(f): fs.append(f) [/code] Then to call a random one (assuming they all take no parameters): [code] import random random.choice(fs)() [/code] Or maybe you only have the name

Re: running a random function

2007-06-07 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, David Bear 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 runnin

Re: running a random function

2007-06-07 Thread Brian van den Broek
David Bear said unto the world upon 06/07/2007 11:56 AM: > 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 a

running a random function

2007-06-07 Thread David Bear
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 -- l