tamilanna.blogg.se

Rthe zen of python
Rthe zen of python












rthe zen of python

Still, when simple solutions are impractical, you are better off implementing the complex solution. The meaning of this aphorism is that valuing simplicity over complexity may be the right way to go in most situations. But just like you wouldn’t wash the dishes with a pressure washer, you wouldn’t wash a car with a small scrubber. The previous observation and this one remind programmers that there are both simple and complex solutions to the same problem. While doing the dishes with a pressure washer is impractical, using the pressure washer may be the right way to go if you’re cleaning a car. Python programmers must avoid overcomplicating their solutions, even if they may look smart and work.Ĭomplicating your programs will ultimately do more damage, and your team will not appreciate it.

RTHE ZEN OF PYTHON CODE

Not to mention, it is a daft solution to the problem.īy the same token, writing complex code to solve a simple program is impractical. Pulling out a pressure washer to clean the dishes after dinner might be one way to go about it, but it’ll likely damage the plates.

rthe zen of python

Put simply, you must write code that another programmer with no previous knowledge of the program should be able to understand how it’s working. Python programmers need to do everything they can to ensure that the functionality of their code doesn’t get hidden behind hard-to-understand language. The idea behind this aphorism is that writing verbose code is better than writing indirect code. But many fail to implement it when they code. Reading this observation, one could conclude that it’s self-explanatory. Removing unnecessary conditions and simplifying your solutions will make your code beautiful. In other words, if a program works fine, it does not mean it’s beautiful and elegant. However, the rule of thumb is that the code must be easy to understand for any developer looking at it. Ideally, the code needs to be readable and elegant.īut what makes code “beautiful”? Just like in life, beauty is subjective in Python programming. Programmers are problem-solving experts, but since writing, documenting, and maintaining Python code is typically a team effort, plainly crafting a solution to a problem is not enough. The Zen of Python: A Breakdown #1 Beautiful is Better Than Ugly We discuss the meanings of the aphorisms and how they can help you improve your code in this post. Python includes the collection as an easter egg, and you can read the list of aphorisms by running “import this” on the interpreter. Bearing these observations in mind when writing code is not mandatory, but it certainly helps ensure quality code. The collection was standardized in 2004 as PEP 20 since it significantly impacted the Python community’s programming process. While the original collection had 20 aphorisms, Guido van Rossum dismisses the final one as a bizarre joke by Peters. The Zen of Python is a collection of 19 observations noted by Tim Peters, one of the creators of Python.














Rthe zen of python