Hacker News new | ask | show | jobs
by StavrosK 3435 days 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.

1 comments

... 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.

I 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.