[Python-Dev] any support for a methodcaller HOF? (original) (raw)
Christian Tismer tismer at stackless.com
Fri Feb 3 19:10:42 CET 2006
- Previous message: [Python-Dev] any support for a methodcaller HOF?
- Next message: [Python-Dev] any support for a methodcaller HOF?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
ciao - chris
-- Christian Tismer :^) <mailto:tismer at stackless.com> tismerysoft GmbH : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9A : Starship http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/
- Previous message: [Python-Dev] any support for a methodcaller HOF?
- Next message: [Python-Dev] any support for a methodcaller HOF?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]