dictionary that have functions with arguments
Alex Martelli
aleax at mail.comcast.net
Wed Nov 2 10:21:55 EST 2005
Leif K-Brooks <eurleif at ecritters.biz> 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 dictionary, not a tuple?
Yes, to call with ** a must be a dict (so {}, not ()).
Alex
More information about the Python-list
mailing list