Re: dictionary that have functions with arguments

2005-11-02 Thread Tim Williams (gmail)
On 1 Nov 2005 20:02:41 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > hi > i have a dictionary defined as > > execfunc = { 'key1' : func1 } ## def __HELLO(x=' '): print 'HELLO',x def __BYE(x=' '): print 'BYE',x def __PRINT(x=None, y=None): print 'PRINT',x,y c

Re: dictionary that have functions with arguments

2005-11-02 Thread Alex Martelli
Leif K-Brooks <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > execfunc = { 'key1' : (func1, ()), > > 'key2' : (func2, args) } > > > > now, something like: > > > > f, a = execfunc[k] > > f(**a) > > > > will work for either key. > > Shouldn't func1's args be a dictiona

Re: dictionary that have functions with arguments

2005-11-02 Thread Ron Adam
Neal Norwitz wrote: > Ron Adam wrote: > >>Eval or exec aren't needed. Normally you would just do... >> >>execfunc['key1'](**args) >> >>If your arguments are stored ahead of time with your function... >> >>Committed revision 41366. Committed revision 41366 ? >>You could then do... >>

Re: dictionary that have functions with arguments

2005-11-02 Thread Leif K-Brooks
Alex Martelli wrote: > execfunc = { 'key1' : (func1, ()), > 'key2' : (func2, args) } > > now, something like: > > f, a = execfunc[k] > f(**a) > > will work for either key. Shouldn't func1's args be a dictionary, not a tuple? -- http://mail.python.org/mailman/listinfo/pytho

Re: dictionary that have functions with arguments

2005-11-02 Thread Neal Norwitz
Ron Adam wrote: > > Eval or exec aren't needed. Normally you would just do... > > execfunc['key1'](**args) > > If your arguments are stored ahead of time with your function... > > Committed revision 41366. > > You could then do... > > func, args = execfunc['key1'] > func(**args)

Re: dictionary that have functions with arguments

2005-11-02 Thread Mike Meyer
[EMAIL PROTECTED] writes: > hi > i have a dictionary defined as > > execfunc = { 'key1' : func1 } > > to call func1, i simply have to write execfunc[key1] . > but if i have several arguments to func1 , like > > execfunc = { 'key1' : func1(**args) } > > how can i execute func1 with variable args? >

Re: dictionary that have functions with arguments

2005-11-02 Thread Ron Adam
[EMAIL PROTECTED] wrote: > hi > i have a dictionary defined as > > execfunc = { 'key1' : func1 } > > to call func1, i simply have to write execfunc[key1] . > but if i have several arguments to func1 , like > > execfunc = { 'key1' : func1(**args) } > > how can i execute func1 with variable ar

Re: dictionary that have functions with arguments

2005-11-02 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: > hi > i have a dictionary defined as > > execfunc = { 'key1' : func1 } > > to call func1, i simply have to write execfunc[key1] . No, you ALSO have to write ( ) [[parentheses]] after that. MENTIONING a function doesn't call it, it's the parentheses that do it. > bu

dictionary that have functions with arguments

2005-11-02 Thread s99999999s2003
hi i have a dictionary defined as execfunc = { 'key1' : func1 } to call func1, i simply have to write execfunc[key1] . but if i have several arguments to func1 , like execfunc = { 'key1' : func1(**args) } how can i execute func1 with variable args? using eval or exec? thanks -- http://mail.