The Zen of Python
The Zen of Python : Image Source - https://realcoderacademy.com/the-zen-of-python/

The Zen of Python

The Zen of Python is a collection of software design principles for the Python programming language. It was written by Tim Peters, one of the early contributors to the Python language, and aims to provide guidance on how to write beautiful and maintainable code. The Zen of Python can be displayed by entering the following command in a Python interpreter:

import?this        

The Zen of Python, by Tim Peters

  1. Beautiful is better than ugly.
  2. Explicit is better than implicit.
  3. Simple is better than complex.
  4. Complex is better than complicated.
  5. Flat is better than nested.
  6. Sparse is better than dense.
  7. Readability counts.
  8. Special cases aren't special enough to break the rules.
  9. Although practicality beats purity.
  10. Errors should never pass silently.
  11. Unless explicitly silenced.
  12. In the face of ambiguity, refuse the temptation to guess.
  13. There should be one-- and preferably only one --obvious way to do it.
  14. Although that way may not be obvious at first unless you're Dutch.
  15. Now is better than never.
  16. Although never is often better than *right* now.
  17. If the implementation is hard to explain, it's a bad idea.
  18. If the implementation is easy to explain, it may be a good idea.
  19. Namespaces are one honking great idea -- let's do more of those!

The Zen of Python is not a set of hard-and-fast rules, but rather a set of suggestions and principles to help guide your thinking as you write code. It is meant to inspire and encourage you to write code that is elegant, readable, and maintainable.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了