Now if you see the source code of this.py file, which you can locate in directory /usr/lib/python on your Linux machine, you will find that the source code disobeys all the guiding principles mentioned in the Zen of Python. Software engineer Tim Peters wrote this set of principles and posted it on the Python mailing list in 1999. The Zen of Python is a collection of 19 "guiding principles" for writing computer programs that influence the design of the Python programming language. Namespaces are one honking great idea - let's do more of those! If the implementation is easy to explain, it may be a good idea. If the implementation is hard to explain, it's a bad idea. There should be one- and preferably only one -obvious way to do it.Īlthough that way may not be obvious at first unless you're Dutch.Īlthough never is often better than *right* now. In the face of ambiguity, refuse the temptation to guess. Special cases aren't special enough to break the rules. Type "help", "copyright", "credits" or "license" for more information. If you run import this on python interpreter, the Zen of Python is printed. I am also a lead in the Woman Who Code Python international chapter, a train enthusiast, a traveler, and a photography lover.Python has an easter egg. I am also a writer on Medium, Built-in, She Can Code, and KDN writing articles about programming, data science, and tech topics. I am an IBM research intern and Qiskit advocate helping build a more quantum future. candidate at Keio University researching ways to test and debug quantum circuits. So, remember, try to follow the guidelines, and your code will be zen-full! Writing good Python code takes practice the more code you write, the better your style will be. Tim Peters originally wrote the poem in his Python mailing list in 1999. The Zen of Python is just a set of 19 guidelines for writing good code (not just in Python). Geeksforgeeks's " How To Approach A Coding Problem?" article about approaching and solving coding problems will help you build the intuition you need to address any problem effectively. Finding the most optimal solution to a programming problem is a skill beyond Python mastery. Some are better and more straightforward than others. In programming and life, there are many ways of handling problems. This brings us to the poem's end, going for the simple and clear way of solving a given problem. The exception Handling In Python YouTube tutorial by Edureka offers a broader view of handling errors in Python. Python Exception Handling: AssertionError article by Frances Banks in AirBrake covers how to use the assert statement optimally. The assert statement is your friend in catching errors and not allowing them to break your code. The next verse is about handling errors and exceptions. This 9 mins video will guide you through writing good, idiomatic Python code. Another option is The Real Python YouTube video about Writing Pythonic Code - Idiomatic Python. Another tremendous and short article about optimizing your Python code is " How to Simplify Your Python Code for Optimal Readability" by Zoe Zbar and Alex Baransky in NYC Data Science Academy. It will give you the basics of how to style your code. Python is about simplicity, so if you want to learn how to write simple Python code with good style, look no further than the Hitchhiker's Guide to Python. The first seven verses in the poem are all about style. Though the poem offers clear and straightforward guidelines for writing succinct Python code, let's talk about some free resources that guide you through the different verses of the poem with examples.
0 Comments
Leave a Reply. |