Python OOP - two numbers - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Python OOP - two numbers (/thread-35083.html) |
RE: Python OOP - two numbers - deanhystad - Oct-01-2021 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. RE: Python OOP - two numbers - ben1122 - Oct-02-2021 (Oct-01-2021, 07:44 PM)deanhystad Wrote: When the PEP talks about multiple statements on one line it means code like this: Oh I didnt talk about the list comprehension, the first thing. But it doesnt matter, I prefer less doing list comprehension, maybe in the future when I will get better at python. Thanks :) |