On Fri, 03 Feb 2006 19:10:42 +0100, Christian Tismer <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote: > >... > >> BTW, re def-time bindings, the default arg abuse is a hack, so I would like >> to >> see a syntax that would permit default-arg-like def-time function-local >> bindings without >> affecting the call signature. E.g., if def foo(*args, **keywords, >> ***bindings): ... >> would use bindings as a dict at def-time to create local namespace bindings >> like **keywords, >> but not affecting the call signature. This would allow a nicer version of >> above-mentioned >> lambda x, zip=zip, zop=zop:x.method(zip,zop) >> as >> lambda x, ***dict(zip=zip, zop=zop):x.method(zip,zop) >> or >> lambda x, ***{'zip':zip, 'zop':zop}:x.method(zip,zop) >> This could also be used to do currying without the typical cost of wrapped >> nested calling. > >Just in case that you might be not aware of it (like I was): >lambda does support local scope, like here: > > >>> def locallambda(x, y): >... func = lambda: x+y >... return func >... > >>> f=locallambda(2, 3) > >>> f() >5 Yes, thanks, I really did know that ;-/ Just got thinking along another line. So lambda x, zip=zip, zop=zop:x.method(zip,zop) and lambda x, ***{'zip':zip, 'zop':zop}:x.method(zip,zop) would better have been (lambda zip,zop:lambda x:x.method(zip,zop))(zip, zop) Regards, Bengt Richter _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com