"Collapsing" a list into a list of changes
Francis Girard
francis.girard at free.fr
Mon Feb 7 16:28:03 EST 2005
Le lundi 7 Février 2005 21:21, Steven Bethard a écrit :
> Francis Girard wrote:
> > Le lundi 7 Février 2005 20:30, Steven Bethard a écrit :
> >>especially since I avoid lambda usage, and would have to write these as:
> >
> > Why avoid "lambda" usage ? You find them too difficult to read (I mean in
> > general) ?
>
> Yup, basically a readability thing. I also tend to find that if I
> actually declare the function, I can often find a way to refactor things
> to make that function useful in more than one place.
>
> Additionally, 'lambda' is on Guido's regrets list, so I'm avoiding it's
> use in case it gets yanked for Python 3.0. I think most code can be
> written now without it, and in most cases code so written is clearer.
> Probably worth looking at is a thread I started that went through some
> stdlib uses of lambda and how they could be rewritten:
>
> http://mail.python.org/pipermail/python-list/2004-December/257990.html
>
> Many were rewritable with def statements, list comprehensions, the
> operator module functions, or unbound or bound methods.
>
> Steve
I see. I personnaly use them frequently to bind an argument of a function with
some fixed value. Modifying one of the example in
http://mail.python.org/pipermail/python-list/2004-December/257990.html
I frequently have something like :
SimpleXMLRPCServer.py: server.register_1arg-place_function(lambda x: x+2,
'add2')
If "Guido" don't like lambdas, he would have to give me some way to easily do
this. Something like (or similar to fit Python syntax) :
SimpleXMLRPCServer.py: server.register_1arg-place_function(\+2, 'add2')
This would be great.
Regards
Francis Girard
server.register_function(operator.add, 'add')
More information about the Python-list
mailing list