On 27/04/2006 10:38 AM, val bykoski wrote:
> Hi The List:
>   I have a modeling app where i'm detecting events (in temporal 
> dynamics) applying a set of (boolean) functions - kind of:
> 
> event_list = "f1 f2 etc".split()  # each fi detects a specific event
> i have defs for functions fi, or simple boolean expressions for each, so 
> that evList is a list of defs or boolean expressions
> for ev in evList:
>    if ev:    # this supposedly is a call ev(t)
>       # doing smth with the event
> 
>    I didn't succeed, though, (blindly) trying various options.
> I thought/tried "apply()" but couldn't get it work.
> I'd appreciate pointers to how to handle this kind of
> functions or events lists (or objects?) and how to call those
> functions in a loop.
>    thanks,val   

This may be something like what you are trying to achieve:

# untested
def fx(arg):
     pass
def fy(arg):
     pass
def fdefault(arg):
     pass

funcmap = {
    'x1': fx,
    'x2': fx,
    'y' : fy,
}

eventlist = "y x2 x2 x1 y".split()
for ev in eventlist:
     efunc = funcmap.get(ev, fdefault)
     if efunc(t): # what is t????
         # do something
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to