PYTHON SENSEI: The Zen of Python

--Originally published at Coding The Future

Well hello there, fellow Python learners! Today, the spirit of one of the great masters of the Python language has inspired me to initiate you into the Python lifestyle. Just like in any discipline or lifestyle, in the Python language, there is a set of basic principles.

This great master, who I previously mentioned is Tim Peters, who in the year 2004 CE found the way to perfection in the Python language. He wrote:

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!

These, my friends, are the ideology on which the Python culture rests. Here's a brief explanation of each:

  • Beautiful is better than ugly: Write code that humans can easily read.
  • Explicit is better than implicit: Use boolean types and avoid implicit loops or functions.
  • Simple is better than complex: If it can be done in a simpler way, do it that way.
  • Complex is better than complicated: If something requires more complexity in order to be more efficient, then take it to that level.
  • Flat is better than Continue reading "PYTHON SENSEI: The Zen of Python"

PYTHON SENSEI: The Zen of Python

--Originally published at Coding The Future

Well hello there, fellow Python learners! Today, the spirit of one of the great masters of the Python language has inspired me to initiate you into the Python lifestyle. Just like in any discipline or lifestyle, in the Python language, there is a set of basic principles.

This great master, who I previously mentioned is Tim Peters, who in the year 2004 CE found the way to perfection in the Python language. He wrote:

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!

These, my friends, are the ideology on which the Python culture rests. Here's a brief explanation of each:

  • Beautiful is better than ugly: Write code that humans can easily read.
  • Explicit is better than implicit: Use boolean types and avoid implicit loops or functions.
  • Simple is better than complex: If it can be done in a simpler way, do it that way.
  • Complex is better than complicated: If something requires more complexity in order to be more efficient, then take it to that level.
  • Flat is better than Continue reading "PYTHON SENSEI: The Zen of Python"