Let’s say, I build a module named “spam” and added submodule “foo” and in it, I added “baz”. Complicated code will suck effort and time! And, programmers can’t afford to lose time.Ĭoders like to create sub-modules for each functionality. Even if the program is complex, try keeping it on the simpler side which can be easily read and understand. It is getting confusing! A complex problem might require a complex technique to overcome it but it shouldn’t be complicated.Ĭomplications in code make fellow programmers confused. Here, you can observe that we have created the output list using list comprehension with conditional. Ranked Among Top (Deemed-to-be University) in India. Numbers 1,2,3,4,5,6,7,8,9,10 evenSquares number2 for number in Numbers if number20 The above code creates a list of squares of even numbers from a given input list Numbers. At JAIN, youll gain a Globally Recognized UG and PG Degree that will Open Doors to a Promising Future. And, now this one says “Complex is better than complicated”. To understand this, consider the following example. The Zen of Python Beautiful is better than ugly. The above aphorism stated that simple is better than complex. Download chapter PDF Author: Tim Peters Abstract Longtime Pythoneer Tim Peterssuccinctly channels the BDFL’s guiding principles for Python’s design into 20 aphorisms, only 19 of which have been written down. Software engineer Tim Peters wrote this set of principles and posted it on the Python mailing list in 1999. You can do the in just two lines of code too. The Zen of Python is a collection of 19 guiding principles for writing computer programs that influence the design of the Python programming language. Print("Reversed String : ", recursion_reverse(original_string)) Why build a complex code when you can build a simpler one. The Zen of Python is an Easter egg, or hidden joke, that appears if you run import this: > import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Hiding code functionality might have repercussions as other programs might not be able to understand the code. It means that it is better to make the code more verbose and explicit. So, why tamper it? Writing clean and readable code is an art which is appreciated by other programmers and let them understand every bit. Python is known for its readability and simplicity. You can open “Easter Egg” in your Python IDE by typing:īeing a developer, writing code and making it run is not the only job to do. Namespaces are one honking great idea - let's do more of those! These are principles that mostly came out of a Smalltalk programming. Errors should never pass silently Before the Zen of Python was a twinkle in Tim Peters' eye, before Wikipedia became informally known as 'wiki,' the first WikiWiki site, C2, existed as a trove of programming guidelines. If the implementation is easy to explain, it may be a good idea. The Zen offers Python's meditation on the topic. 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.
0 Comments
Leave a Reply. |