3 ms·
Yeah it was pretty good in the Python 2 era but definitely not something to copy now. Another big issue is that it's not expression based. For example you can'
by IshKebab 3y ago
Yeah it was pretty good in the Python 2 era but definitely not something to copy now.
Another big issue is that it's not expression based. For example you can't do `foo = (yield a).b` you have to do `x = yield a; foo = x.b`.
Having a special syntax for the expression version of if else is another example as you said.
I was disappointed to discover Dart made the same mistake there. There's a totally different syntax for match statements and match expressions. Why?? Ok maybe backwards compatibility.. but still. They fixed nullability properly and it wasn't too bad.
- ptx 3y ago> For example you can't do `foo = (yield a).b` you have to do `x = yield a; foo = x.b`. The first snippet actually works fine. Yield expressions were introduced with PEP 342 in Python 2.5.
- IshKebab 3y agoAh I misremembered. I was actually trying to do this x = [yield a for a in b] Which yields (heh) an `Invalid Syntax` error. Thanks for the link to that PEP though - turns out the answer is that you almost always have to parenthesise it. x = [(yield a) for a in b] > SyntaxError: yield inside list comprehension Ok my original point stands.
- bafe 3y agoThe fact python is statement-heavy to me shows that it was originally conceived in another age. It is really annoying after you use expression oriented languages