Pythonic
Pronunciationpie-THON-ik
Definition
Code that follows Python's style and uses the language's own features, so it reads naturally to Python developers.
Where you hear it
Python code reviews and style discussions.
Examples
A list comprehension is more Pythonic than a manual loop here.
That works, but it is not very Pythonic.
Using enumerate instead of a manual counter is more Pythonic.
Common mistake
Squeezing everything into one clever line. Pythonic means readable, not shortest.
Say it at work
- In a meeting or chat
I think we can make this logic more Pythonic by using a generator expression instead of that nested loop.
- In an email or ticket
Please refactor the data processing module to follow Pythonic conventions, specifically by utilizing context managers for file handling.
Keep exploring
More in Programming Fundamentals