On this page
article
Tip #119: Use list comprehensions for simple transforms
Python tip #119: Use list comprehensions for simple transforms.
Tip
Use list comprehensions for simple transforms
Why
Following this practice makes your Python code more readable, maintainable, and less error-prone.
Example
# Before (avoid)
# ... less idiomatic approach ...
# After (prefer)
# ... idiomatic Python 3.10+ approach ...