3 ms·
As a Python programmer of 10+ years, here's the most Pythonic tip you can get: Don't try to be clever, do the simplest (and most readable) thing that will work
by StavrosK 10y ago
As a Python programmer of 10+ years, here's the most Pythonic tip you can get:
Don't try to be clever, do the simplest (and most readable) thing that will work.
Try "import this" in an interpreter to read a bit more on the above.
- shakna 10y ago... Except generators and comprehensions are often faster than for loops in your hot path. Apart from that... What's readable tends to be the best option.
- swsieber 10y agoI think the Python community considers list comprehension more readable than loops. And writing generators allows you to write simple code with them. I don't consider generators to be fancy - just a tool to pull out complexity into a small area and make the rest of the code readable.