5 ms·
I find it always decreases readability. I literally cannot read C code that does this, now I'm going to have to worry about encountering unreadable Python code
by amyjess 8y ago
I find it always decreases readability.
I literally cannot read C code that does this, now I'm going to have to worry about encountering unreadable Python code.
Edit: Also, it violates both "explicit is better than implicit" and "there should be one and only one right way to do it". It's inherently Unpythonic.
- mixmastamyk 8y agoIt's explicit with the new operator. The latter is true however.
- klodolph 8y agoI agree that it's a violation of the “one and only one” maxim, but that maxim is a bit hard to take as an absolute. I think the problem is that there are already a lot of ways to write things in Python, the biggest example that comes to mind is list comprehensions. outputs = [f(x) for x in inputs] Versus: outputs = [] for x in inputs: outputs.append(f(x)) The assignment expression lets you: outputs = [y for x in inputs if (y := f(x)) is not None] I know that more complicated list comprehensions in Python are a bit of a sore point for some people, but I would say that they’re also inherently unpythonic, and I like them.
- legostormtroopr 8y agooutputs = [y for x in inputs if (y := f(x)) is not None] I can't stand this new syntax, y is declared and assigned after the first instance of its use.
- michaelcampbell 8y ago> I literally cannot read C code that does this, Hogwash. You choose to not.