add_command

Gorny gorny0 at zonnet.nl
Mon May 13 03:35:02 EDT 2002


"Alex Martelli" <aleax at aleax.it> schreef in bericht
news:5nxD8.33442$CN3.1163150 at news2.tin.it...
> Gorny wrote:
> >
> > status.add_command(label='wh00t', command=self.func,
> > argskeyword=tuple_containing_args)
>
> If it's a tuple it's unlikely to hold _keyword_ arguments --
> more likely it will hold positional ones, no?

Aargh of course...*flame me*

> Anyway, the special-case you need is something line (in Python 2.2,
> or 2.1 with "from __future__ import nested_scopes"):
>
> def curry(func, *args, **kwds):
>     def curried(): return func(*args, **kwds)
>     return curried
>
> then you'll call something like
>
> status.add_command(label='wh00t',
>   command=curry(self.func, *tuple_containing_args))

Allright, that'll do fine. I've read the corresponding PEP and it seems
perfectly clear to me. But in the future (as of 2.3) I assume that you
don't have to import anything and the nested_scopes are implemented
within Python's core?

Gorny

--
"Spread the sources"
http://gorny.cjb.net







More information about the Python-list mailing list