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
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
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...
>>
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
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)
[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?
>
[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
<[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
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.