Anonymus functions revisited
Claudio Grondi
claudio.grondi at freenet.de
Tue Mar 22 04:41:01 EST 2005
For me, one of the reasons for using Python
is the ease and the intuivity of reading its
code.
I have a problem with intuitively getting
what is going on when using a pattern like
(x,y,z=0) -> (x,y,z)
where I expect at the first glance some
C code with access to class members.
At least I must start looking at the code
more closely thinking why is someone
using such a construct.
Already
lambda x,y,z=0:(x,y,z)
is a problem for me.
Why not:
try:
(x,y,z)
except NameError:
z=0
(x,y,z)
?
Watching the last piece of code
can even directly be seen, that there
is eventually a NameError
problem with z to handle,
so where is the gain of using
lambda or the mapping?
My current conclusion (I can't see any gain):
No, thanks.
Claudio
"Kay Schluehr" <kay.schluehr at gmx.net> schrieb im Newsbeitrag
news:1111473420.674542.209610 at z14g2000cwz.googlegroups.com...
> 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?
>
> Regards Kay
>
More information about the Python-list
mailing list