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):
          p = 'spam' if flag else 'ham'
          return obj.method(**{p:arg})
       return foo

is the obvious way in that style.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to