When he'd find a beautiful proof, he would say “This one is from The Book!”. Paul Erdös, a prolific mathematician of the 20th century, often talked about “The Book”:Ī book where the most elegant proofs for mathematical theorems had been written by a divinity. One mathematician even took that to an extreme. There are many theorems that can be proven in many different ways,īut mathematicians always try to find the most elegant proof. Striving to write elegant code might seem weird, but it's not! So, if your code is elegant, it is more likely to be good code. I take this to mean that aesthetics do matter, If you would like to engage in thoughtful discussion about the Zen of Python, or about any particular guideline, just scroll down to the bottom of the page and leave a comment there! Beautiful is better than ugly If you disagree with me, that doesn't mean one of us is wrong! My interpretations will reflect my personal experience, my thoughts, my opinions, etc. Having said that, I would like to share my interpretation of some of the guidelines outlined in the Zen of Python. Thinking about it, and discussing it with others. The Zen of Python is a text that is open to interpretation and you should keep that in mind when reading it, The Zen of Python is not splitting hairs and making sure we come up with an objective metric that we can use to rank Python code. Sometimes, saying what something is not is as important, Writing code is the same: chances are, the first thing you write can be greatly I usually write a first draft and then go over it, editing as I see fit: sometimes Or a blog post, I never get it right on the first try. I don't know about you, but whenever I write a (text) document, like a letter Zen of Python while you code and while you go over code that has already been My advice would be to read this from time to time, and to try and remember the You will only become a true Pythonista after you embrace the Zen of Python. Practitioners: Po was only able to take his kung fu skills to the next level,īecoming truly amazing, after embracing the Dragon Scroll. The Zen of Python is to Python programmers what the Dragon Scroll is to kung fu If you've seen the Kung Fu Panda, think of it this way: Recommendations are serious and should not be taken lightly - if you are willing Within the spirit of the language”, which goes to show that these Guidelines are “ fundamental idiomatic recommendations for operating That Tim Peters (a major contributor to Python in its earlier days) thinks that these If you want to write truly Pythonic code, then you should try to embrace theseĭigging in the reference of PEP 20 - The Zen of Python shows Take a look at those guidelines and try to appreciate their meaning. 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. Should print the following text: The Zen of Python, by Tim Peters You can read the Zen of Python by executing import this in your REPL, which With the guidelines that you should follow when thinking about (Python) codeĪnd when designing a program. Your code, how to name your variables, etc., the Zen of Python provides you While you have things like PEP 8 that tell you how you should format The Zen of Python is like a meta style guide. That all Pythonistas should be aware of: the Zen of Python. To kick-off the Pydon't series we start with a set of guidelines If you are looking to write Pythonic code, write code that abides by the Zen of Python. If you have never read them before, read them now and again from time to time. The " Zen of Python" is the set of guidelines that show up in your screen if you import this.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |