Oct-01-2021, 07:44 PM
When the PEP talks about multiple statements on one line it means code like this:
squares = []; cubes = [] for x in range(10): squares.append(x**2); cubes.append(x**3) print(squares); print(cubes)Each line has multiple expressions. The PEP is not condemning list comprehensions or a conditional expressions/ternary operators. A list comprehension is a single statement. Maybe a complex looking statement, but still a single statement/expression. Once you get comfortable using them you'll find yourself seeking opportunities to use them.