Ideas for Python 3
Josiah Carlson
jcarlson at uci.edu
Wed May 5 11:47:05 EDT 2004
> The problem with this suggestion ( and many other similar uses of
> existing functions ) is that it relies on a regular mathematical
> sequence. Think of a more general case, something like:
>
> L = [:x:x**2, :x:x+4, :x:x/5, :x:2-x, :x:x*7 ]
Ick.
> Q1) Is it worth having a "lambda" syntax like this, or should we just
> deprecate lambda functions entirely and use:
>
> def f1(x): return x**2
> def f2(x): return x+4
> def f3(x): return x/5
> def f4(x): return 2-x
> def f5(x): return x*7
> L = [ f1, f2, f3, f4, f5 ]
Don't deprecate lambda. I know Guido is hot to do so, and believes it a
mistake to have in the first place, but is it really hurting anyone?
Sure, those who don't know how to use them, but the barrier for entry is
quite low.
> Q2) Will it help new users to have the "lambda" syntax be as close as
> possible to a normal function definition? i.e.
>
> f :(x): return x**2 # a simple function
> :x:x**2 # equivalent lambda expression
>
> -- or --
>
> f = def(x): return x**2
> def x:x**2
Ick on the four options just given.
> I am especially interested in feedback from users who have recently
> learned Python. I suspect that many experienced users will have long
> forgotten any difficulties they had while learning.
Lerning lambda expressions are trivial when you have experience with
derivatives of LISP. While I generally don't like to point users off to
go RTFM, in this case, 5 minutes of manual reading (without LISP
experience) will go a long way toward understanding lambda expressions.
- Josiah
More information about the Python-list
mailing list