Python·100 questions

How to write readable code: small functions, clear names?

Answer
One function — one responsibility.
Clear names are more important than comments.
Avoid “magic” numbers — put them in constants.
Write docstring for public API.
Refactor if it becomes hard to read.
Was this answer helpful?

More questions in this topic

Related questions from other topics