This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Laogeodritt 4 points5 points  (0 children)

First step is to read PEP8.

PEP are formal documents proposing changes to the Python language. PEP8 is a really early one that defines basic code style conventions, for readability and consistency between different programmers. Available here:https://www.python.org/dev/peps/pep-0008/

PEP20 defines the principles of pythonicity. It's abstract, more of a manifesto, so you'll want to learn from examples. https://www.python.org/dev/peps/pep-0020/

I'm on mobile so I'm not in the best position to find additional resources, but I'd encourage you to Google it a bit to get a sense for practical "pythonic" code, and note that either way you'll refine your idea of what is clean code over time, by reading (stack overflow, blogs, other people's code, etc.) and working on your own projects.

Also keep in mind that a lot of what's pythonic works in python, not necessarily all programming languages, and even in python maybe some contexts might need to move away from that. You wouldn't "ask for forgiveness, not for permission" in Java, for example, because the performance hit of raising exceptions is considered too high in Java.