Re:Python 3.8.0a1 is now available for testing
by klodolph on Monday February 04, 2019 @01:33PM
(#19079156)
I 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.
Re:Python 3.8.0a1 is now available for testing
by legostormtroopr on Monday February 04, 2019 @04:59PM
(#19081053)
outputs = [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.
Re:Python 3.8.0a1 is now available for testing
by mixmastamyk on Monday February 04, 2019 @01:11PM
(#19078869)
It's explicit with the new operator. The latter is true however.
Re:Python 3.8.0a1 is now available for testing
by michaelcampbell on Tuesday February 05, 2019 @11:19AM
(#19086699)
> I literally cannot read C code that does this,
Hogwash. You choose to not.
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.