The ZEN of Python
Introduction & principles to the zen of python:
The 19 guiding guidelines that govern Python's design make up the "zen of Python."
Tim Peters, a software developer, wrote the tenets and requested that Guido van Rossum, the man behind Python, add a twelfth. However, this never occurred. Therefore, there are currently 19. PEPs (Python Enhancement Proposals) are publications that describe new features for Python or provide crucial information to the Python community. PEP-20 consists solely of a list of these 19 principles. These rules are included in PEPs to highlight their significance to the Python community. Python is an essential tool for anyone starting in data science because it is used widely in the field and is only becoming increasingly popular. You will be a stronger candidate if you learn Python as part of the larger data science skill set because data researchers are predicted to have many skills.
1. Better than ugly is beautiful
If there are two snippets present, the two codes are working. The first one is very readable and neat, which the normal person understands. The second snippet Is very hard and messy, which is hard to understand by the normal programmer. The first code is the winner because python is also known for code elegance, simplicity, and readability.
Pay attention to your code's uniformity and simplicity if you want it to appear pythonic.
2. Implicit is not better than the explicit
If you write code, it should be understandable by a normal person who knows nothing. He needs to gain basic knowledge about that code. We have to make our code explicit and reduce the functionality behind obscure language.
3. Simple >>> Complex
If you have a problem, first you solve it and try to get an efficient solution. If you are getting two solutions, one simple and the other complex, we have to choose the simple one. If we got only one solution, we should break down the solution into parts, so we should keep the solution simple. The simple solution is encouraged by python.
4. Complex >>> Complicated
Even though a complex solution is needed for your situation, it shouldn't be overly convoluted. Complicated code wastes time and effort and confuses your other programmers. Even when dealing with difficult issues, keep your code as straightforward and legible as possible.
5. Flat >>> Nested:
Only go for her if you are sick of the flat structured code. Frequently, a hierarchical structure causes more confusion than it does organization. The main point is code readability.
6. Readability matters:
The code may only be written once but must be read several times. Make your code understandable by utilizing clear variable and function names, thorough documentation, and appropriate indenting if you genuinely want to save time.
7. Practicality Beats purity:
Even if there may be exceptions to any rule, you may occasionally break from accepted best practices if doing so makes the code legible and easy to comprehend. It is more practical to tackle the problem that way. The transition between this and the preceding principle might be difficult for beginners in programming, but it becomes simpler with practice.
8. Errors should not pass quietly:
If your code returns the none or error code, then your code passes quiet.
This may lead to bugs, which may take work to fix. Crashing a program is preferable to masking a problem and allowing it to continue.
9. It might be a nice concept if the implementation is simple to explain:
It would be good to explain your code to others or co-workers. It indicates that you are on the right track regarding code readability and simplicity.
Advantages:
- It will make sure that every person can understand the code.
- It will be a simple code.
- Errors cannot be passed silently.
- Most of the time, flat code is used instead of nested code. Times, it should be complex better than complicated.
Disadvantages:
- The main disadvantage is that the code runs slowly.
- In many cases, it will show the run time errors. The speed of execution always is hampered.
- database access could be developed better.
- It is used for backend programming.