5 ms·
`if x < 3: x = 3` is valid Python, although I see your point - you could add an `else` to the Lua example but Python would require a second line. > a form for
by pansa2 5y ago
`if x < 3: x = 3` is valid Python, although I see your point - you could add an `else` to the Lua example but Python would require a second line.
> a form for short Python-style lambdas would really help
Interesting - many in the Python community feel that its lambdas (particularly the use of `lambda` as a keyword) are too verbose and would prefer something like `x => x+1`. Maybe such an arrow-function syntax is achievable with Python's new PEG parser - I'm fairly sure it couldn't have been supported by the old LL(1) parser.
- kzrdude 5y agoIn this particular example, Python has the more wordy `x = 3 if x < 3 else x` which you'd rather write as `x = max(x, 3)` to demonstrate Python's muscles in terms of useful builtins. About lambda syntax, to me it would be far more important to allow multiline lambdas than to have a shorter keyword.
- pansa2 5y ago> `x = max(x, 3)` to demonstrate Python's muscles in terms of useful builtins Even Lua has a built-in `math.max` function that works with integers. Maybe it’s Lua’s way of flexing on Go :) > About lambda syntax, to me it would be far more important to allow multiline lambdas than to have a shorter keyword. Never going to happen, unfortunately. It’s just not possible within the fundamental rules of Python’s grammar: that statements use significant indentation and expressions do not.
- deleted 5y ago[deleted]
- scythe 5y agoAll good points. Just compare: (lambda x: x + 1) (function (x) return x + 1 end) For arrow syntax I like this: ((x) -> x + 1) but reducing the number of keyword characters from 17 to 6 is already a big win.