[Python-ideas] Syntactic sugar to declare partial functions

Abe Dillon abedillon at gmail.com
Mon Aug 13 16:26:38 EDT 2018


[Chris Angelico]

> > The whole point of a programming language is to bridge the gap between
> > machine code and natural language (in Python's case English, as with most
> > other languages). It's to make reading and writing code easier through
> > abstraction, not to create ivory towers through the use of esoteric
> jargon.
> > It's not supposed to make a cool kids club for people privileged enough
> to
> > study CS in college. At least that's not my goal.
> The whole point of a car is to make driving easier through abstracting
> away the internal details of petrochemical propulsion, but if someone
> says "I don't want to know about 'gears' or 'brakes' or any of these
> technical terms", you wouldn't want them driving on the roads you're
> on. There is a certain level of comprehension that you can't avoid.
> (If you don't know anything about how to use a car, you can still ride
> in one, but you can't drive it; and you don't need to understand about
> anonymous functions in order to operate a computer, but you'll need
> them to program effectively.)


This was originally in response to Bruce Leban's assertion: "If using
lambda as a keyword leads people to go and learn about lambda calculus that
is a good thing."

Are you saying that knowing "what lambda calculus is" is as important to
programming in Python as knowing "what breaks are" is to driving? If so, I
don't think that analogy holds water. I don't think lambda calculus is
fundamental to knowing how to write a program. I don't even think anonymous
functions are fundamental to writing a program. I think a programmer could
go their whole life without ever knowing what a lambda expression is and
still manage to write plenty of very useful code.

It seems to me like the whole point of this discussion has turned into
getting me to repent and profess my undying love for lambda expressions.
I'm sorry to disappoint.

Maybe we should split off this discussion into a thread where people can
keep badgering me to come up with an objective proof that Python's lambda
expressions are not the best implementation possible. Then, at least, we
can stop polluting this thread with this tangent.

It doesn't seem to matter how many times I try to point this out, but my
original comment should be read as: "I like Steven's idea. I prefer `given`
to `partial`." I'm sorry I even brought up lambda. I'm truly sorry to all
those who wanted to seriously discuss alternatives to functools.partial.

On Mon, Aug 13, 2018 at 2:17 PM, Chris Angelico <rosuav at gmail.com> wrote:

> On Tue, Aug 14, 2018 at 5:08 AM, Abe Dillon <abedillon at gmail.com> wrote:
> > The whole point of a programming language is to bridge the gap between
> > machine code and natural language (in Python's case English, as with most
> > other languages). It's to make reading and writing code easier through
> > abstraction, not to create ivory towers through the use of esoteric
> jargon.
> > It's not supposed to make a cool kids club for people privileged enough
> to
> > study CS in college. At least that's not my goal.
>
> The whole point of a car is to make driving easier through abstracting
> away the internal details of petrochemical propulsion, but if someone
> says "I don't want to know about 'gears' or 'brakes' or any of these
> technical terms", you wouldn't want them driving on the roads you're
> on. There is a certain level of comprehension that you can't avoid.
> (If you don't know anything about how to use a car, you can still ride
> in one, but you can't drive it; and you don't need to understand about
> anonymous functions in order to operate a computer, but you'll need
> them to program effectively.)
>
> > As someone who has taught Python professionally, I can say that there is
> a
> > strange mental block regarding lambda expressions. Pretty much every
> student
> > I've had has struggled with lambda expressions, even those who grasp
> > similarly complex constructs like decorators with ease. This includes
> > students who learned english as a second language. I can only attribute
> that
> > to the word 'lambda' being confusing as hell.
>
> As someone who currently teaches both Python AND JavaScript
> professionally, I can say that there is a strange mental block
> regarding anonymous functions, and it's nothing to do with the word
> "lambda". In JavaScript, anonymous functions are created with the word
> "function" (same word as is used for declared functions), and there
> are just as many points of confusion as there are with Python.
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180813/6f02d1a2/attachment.html>


More information about the Python-ideas mailing list