Python doesn't need more features but better implementations, IMO.
Edit: Just remembered the Zen of Python, I don't think modern Python is following it.
...
Simple is better than complex.
...
Readability counts.
...
There should be one-- and preferably only one --obvious way to do it.
Having one way of doing something and sticking with it even when better ways emerge is nonsensical imo.
f-strings are more readable (for me) and concise than string formatting or .format()
I do agree on the implementation front though, many of the other implementations are still on 2.7 or 3.6 at most, and don't have mainstream appeal. Made more with interop in mind (like ironpython with .net and jython with the jvm)
Not for beginners though. One of Pythons main strengths was that it looked simple. Not anymore.
Point is Python used to be a complete yet simple language with few constructs. It more or less followed the path of least surprise and people revered it for that. For several years, it feels like PEPs just add more and more clutter to that foundation.
It sort of looks like an arms race and I just don't get why or what's going on. Certainly, Python doesn't feel the same anymore.
elif cmd.op == 'TUPLE':
arity, = cmd.args
tuple_args = []
for _ in range(arity):
tuple_args.append(self.data_stack.pop())
result = '{' + ', '.join(map(str, tuple_args)) + '}'
self.data_stack.append(result)
Is following use of comprehension any better? I don't think so: elif cmd.op == 'TUPLE':
arity, = cmd.args
tuple_args = [str(arg) for arg in reversed(self.data_stack[-arity:])]
self.data_stack = self.data_stack[:-arity]
result = '{' + ', '.join(map(str, tuple_args)) + '}'
self.data_stack.append(result)
Any other suggestions for improvement?There's usually a threshold where I go "nope" and unroll it into a good old loop.
But when you're in their sweet spot, they definitely improve readability.
elif cmd.op == 'TUPLE':
arity, = cmd.args
stack = self.data_stack
text = ', '.join(str(stack.pop())
for _ in range(arity))
stack.append(f'{{{text}}}')Buy I personally like it when I read other people's code and see something which I don't understand, which I've never seen, and then it turns out to be a feature which actually makes coding easier and more efficient. Then I think about all the places where I could have used that feature in my old code.