Tuesday, April 4, 2017

The Python “Secret Handshake”


I’ve been involved with Python for some 18 years now as of this writing in 2010, and I have seen it grow from an obscure language into one that is used in some fashion in almost every development organization and a solid member of the top four or five most widely-used programming languages in the world. It has been a fun ride. But looking back over the years, it seems to me that if Python truly has a single legacy, it is simply that Python has made quality a more central focus in the development world. It was almost inevitable. A language that requires its users to line up code for readability can’t help but make people raise questions about good software practice in general. Probably nothing summarizes this aspect of Python life better than the standard library this module—a sort of Easter egg in Python written by Python core developer  Tim Peters, which captures much of the design philosophy behind the language. To see this for yourself, go to any Python interactive prompt and import the module (naturally, it’s available on all platforms):

 >>> import this
 The Zen of Python, by Tim Peters
 Beautiful is better than ugly.
 Explicit is better than implicit.
 Simple is better than complex.
 Complex is better than complicated.
 Flat is better than nested.
 Sparse is better than dense.
 Readability counts.
 Special cases aren't special enough to break the rules.
 Although practicality beats purity.
 Errors should never pass silently.
 Unless explicitly silenced.
 In the face of ambiguity, refuse the temptation to guess.
 There should be one-- and preferably only one --obvious way to do it.
 Although that way may not be obvious at first unless you're Dutch.
 Now is better than never.
 Although never is often better than *right* now.
 If the implementation is hard to explain, it's a bad idea.
 If the implementation is easy to explain, it may be a good idea.
 Namespaces are one honking great idea -- let's do more of those!
 >>>


Worth special mention, the “Explicit is better than implicit” rule has become known
as “EIBTI” in the Python world—one of Python’s defining ideas, and one of its sharpest
contrasts with other languages. As anyone who has worked in this field for more than
a few years can attest, magic and engineering do not mix. Python has not always fol-
lowed all of these guidelines, of course, but it comes very close. And if Python’s main
contribution to the software world is getting people to think about such things, it seems
like a win. Besides, it looked great on the T-shirt.



No comments:

Post a Comment

Remote Hybrid and Office work