Steven D'Aprano wrote:
> On Sun, 23 Sep 2007 03:55:45 -0500, Ron Adam wrote:
>
>> Steven D'Aprano wrote:
>>> I'm writing a factory function that needs to use keywords in the
>>> produced function, not the factory. Here's a toy example:
>
> [snip]
>
> Thanks everyone who answered, you've given
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> A valuable lesson... always measure before guessing whether code
> will be slow or not.
And after measuring, don't guess then either :-)
--
\"Science doesn’t work by vote and it doesn’t work by |
`\ authority." —Richard D
On Sun, 23 Sep 2007 03:55:45 -0500, Ron Adam wrote:
> Steven D'Aprano wrote:
>> I'm writing a factory function that needs to use keywords in the
>> produced function, not the factory. Here's a toy example:
[snip]
Thanks everyone who answered, you've given me a lot of good ideas.
I've run some t
On 9/23/07, Ron Adam <[EMAIL PROTECTED]> wrote:
>
>
> Steven D'Aprano wrote:
> > I'm writing a factory function that needs to use keywords in the produced
> > function, not the factory. Here's a toy example:
>
http://docs.python.org/whatsnew/pep-309.html
--
http://mail.python.org/mailman/listinfo
Steven D'Aprano wrote:
> I'm writing a factory function that needs to use keywords in the produced
> function, not the factory. Here's a toy example:
> I thought of doing this:
>
> def factory(flag):
> if flag: kw = 'spam'
> else: kw = 'ham'
> def foo(obj, arg):
> kwargs =
On Sep 22, 10:53 pm, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> I'm writing a factory function that needs to use keywords in the produced
> function, not the factory. Here's a toy example:
>
> def factory(flag):
> def foo(obj, arg):
> if flag:
> # use th
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> def factory(flag):
> if flag: kw = 'spam'
> else: kw = 'ham'
> def foo(obj, arg):
> kwargs = dict([(kw, arg)])
> return obj.method(**kwargs)
> return foo
Untested:
def factory(flag):
def foo(obj, arg):