Young Jedi Anmol Tomar, your pythoninc knowledge lacks historical viewpoint. List Comprehensions were the Python Enhancement Proposals( PEP) 202.
In fact Anmol Tomar wrote on medium.com “9 Python Mistakes That Reveal You’re a Nooby! Move away from noob status!”. Too bad he want to be read only by people in medium walled garden. The fist is readable:
1. Neglecting Pythonic Idioms
Python has its own set of idioms and best practices that make your code more elegant and readable. A common mistake among newcomers is writing code in a non-Pythonic way.
For example, using excessive loops when list comprehensions or generator expressions could provide a more concise solution. Embrace Pythonic idioms to improve the readability and maintainability of your code.
Wrong
# Non-Pythonic way
squared_numbers = []
for i in range(1, 6):
squared_numbers.append(i ** 2)In this example, using a list comprehension provides a more concise and readable solution compared to the traditional loop and append approach.
Correct
# Pythonic way
squared_numbers = [i ** 2 for i in range(1, 6)]
Young Jedi, your pythoninc knowledge lacks historical viewpoint. The “non python way” was the only pythonic way back in the 1.5.x days.