[Python-Dev] Use an empty def as a lambda (original) (raw)
Westley Martínez anikom15 at gmail.com
Sat Sep 21 21:22:14 CEST 2013
- Previous message: [Python-Dev] Use an empty def as a lambda
- Next message: [Python-Dev] Use an empty def as a lambda
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
When I say Python 4000, I don't actually mean Python 4.x, I mean the next backwards-incompatible revision to Python (if it comes to pass). My reasoning is that we use class to make classes, lambda to make lambda functions, and def to make--well not defs--functions, which doesn't really make sense to me.
Changing lambda to def would break compatibility as well and restrict the grammar further. In addition, it provides little foreseeable benefit since the term def has no real meaning outside of Python, whilst lambda has a clearly defined meaning. Had the original C pro- grammers chosen def in lieu of typedef or #def in lieu of #define, I doubt that def would have been chosen as the keyword for functions in Python.
-----Original Message----- From: Ryan [mailto:rymg19 at gmail.com] Sent: Saturday, September 21, 2013 10:55 AM To: Westley Martínez; 'Ben Gift'; python-dev at python.org Subject: Re: [Python-Dev] Use an empty def as a lambda
Change def to func? That's the worst idea I've heard yet. Def is already there; why break all existing code just for a word?
"Westley Martínez" <anikom15 at gmail.com> wrote: 'def' is no more ambiguous than 'lambda', and is in fact more ambiguous, for 'def' doesn't lend itself to anything other than the word define, whilst 'lambda' can only mean lambda function. Calling def explicit is silly. It only makes sense because def arbitrarily means a function in Python (I'm proposing def become func or proc in Python 4000). To call lambda too 'computer sciencey' is equally ridiculous, for pro- gramming is a key spawn of computer science. A programmer needs to have some knowledge of computer science to program, just like a physicist needs knowledge of calculus to understand mechanics. -----Original Message----- From: Python-Dev [mailto:python-dev-_ _bounces+anikom15=gmail.com at python.org] On Behalf Of Ben Gift Sent: Thursday, September 19, 2013 1:54 PM To: python-dev at python.org Subject: [Python-Dev] Use an empty def as a lambda I think the lambda keyword is difficult to understand for many people. It would be more pythonic to use an empty def call instead. For instance this: words.sort(key = lambda x: x[2]) could look like this: words.sort(key = def (x): x[2]) It's obvious and explicit that we're creating an unnamed, anonymous function this way.
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python- dev/rymg19%40gmail.com -- Sent from my Android phone with K-9 Mail. Please excuse my brevity.
- Previous message: [Python-Dev] Use an empty def as a lambda
- Next message: [Python-Dev] Use an empty def as a lambda
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]