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)
which is in fact not a valid solution in the context of Georges' problem... (or I failed to get it to work !-)
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).
Changing my mind after a more torough re-reading of the original thread and few tests... The original problem is about tuple unpacking. The proposed solution solves this problem, *and* can (could ?) be a replacement for lambdas.
hmmm... I like the idea of having a more flexible tuple unpacking with a function-call-like semantic, but I'm still not sure to like the idea of replacing lambda with the proposed syntax.
needs-some-more-thinking-on-this-ly'yrs
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])"
--
http://mail.python.org/mailman/listinfo/python-list