4 ms·
> So with JavaScript you've got arrow functions, the method shorthand definition syntax, the spread operator, destructuring assignments, all functional Array me
by devnonymous 9y ago
> So with JavaScript you've got arrow functions, the method shorthand definition syntax, the spread operator, destructuring assignments, all functional Array methods and async functions.
In language that pythonistas would grok:
Arrow functions: multiline lambda definitions
method shorthand definition syntax: class defined with only classmethods, or in other words a namespace
the spread operator: *args in functions
destructuring assignments: tuple unpacking... But also for creation of instances
all functional Array methods and async functions: functools and async... Plus a bit more
While most of this is good to know, I'd still stick with python for readability and maintainability purposes.
- creatonez 9y agoIMO arbitrary rules like lambda expressions being limited to one expression do not directly improve readability and maintainability. Consistently using good conventions in the first place will help you more than arbitrary restrictions. And to be clear, I would classify, say, Rust as not having many arbitrary restrictions. All the limitations that Rust has compared to C fit clearly within the language's core design. On the other hand, I don't see this same structure and consistency to some of Python's rules.
- dragonwriter 9y ago> IMO arbitrary rules like lambda expressions being limited to one expression do not directly improve readability and maintainability. In Python’s specific case, I've seen no alternative that isn't bad for readability; the strong line-orientation of Python's broader syntax limits the good options for inline anonymous functions. That being said complex lambdas in general can be adverse to maintainability and Python’s single-expression limitation largely prevents that (though you can make hideously complex opaque single-expression lambdas if you try.)