Anonymus functions revisited

bruno modulix onurb at xiludom.gro
Tue Mar 22 05:17:22 EST 2005


Kay Schluehr wrote:
> Since George Sakkis proposed a new way of doing list comprehensions
> 
> http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/ac5023ad18b2835f/d3ff1b81fa70c8a7#d3ff1b81fa70c8a7
> 
> letting tuples-like objects (x,y,z=0) acting as functions on other
> tuples I wonder why this would not be a good starting point of
> rethinking anonymus functions?
> 
> In Georges proposition the action is
> 
>    (x,y,z=0) -> (x,y,z)
> 
> i.e. mapping tuples on other tuples. This is equivalent to
> 
> lambda x,y,z=0:(x,y,z)
> 
> But regarding tuples as actions by means of an arrow "->" would
> generalize this idea:
> 
> Mappings like that:
> 
>    ((x,y),z)   -> x+y-z
> 
>    ((x,y=0),z) -> None
> 
> should be valid actions too.
> 
> What is the audience thinking about that?

IMHO, it's just lambda in disguise, and I'm not sure it's more readable 
than lambda. You'll have to provide more arguments (sorry for the pun 
!-) to gain my adhesion. (NB : I could use this syntax without problem, 
it's just that we already have a syntax for this).


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for 
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list