Anonymus functions revisited

Antoon Pardon apardon at
Tue Mar 22 10:53:23 CET 2005

Op 2005-03-22, Claudio Grondi schreef <claudio.grondi at>:
> 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)
> ?

Because they are not equivallent.

> Watching the last piece of code
> can even directly be seen, that there
> is eventually a NameError
> problem with z to handle,

And suppose there is a NameError with x,
your piece of code will then assign 0 to
z. Do you think that is what the original
code wanted?

> so where is the gain of using
> lambda or the mapping?

Is is usable as an argument.

Antoon Pardon

More information about the Python-list mailing list