Content deleted Content added
Erictleung (talk | contribs) →In practice: Added more research to exploring Zen of Python in practice |
Erictleung (talk | contribs) Add introduction sentence on being Pythonic |
||
Line 7:
|website=The Hitchhiker’s Guide to Python
|date=2011–2019
|access-date=March 26, 2019}}</ref> Python code that aligns with these principles is often referred to as "Pythonic".<ref name=":1" />
[[Software engineer]] [[Tim Peters (software engineer)|Tim Peters]] wrote this set of principles and posted it on the Python [[mailing list]] in 1999.<ref name="Peters 1999-06-04">{{cite web
Line 57:
== Being Pythonic ==
One of the principles, "There should be one-- and preferably only one --obvious way to do it", can be referenced as the "Pythonic" way.<ref name=":0" /> The official definition of "Pythonic" is:<ref name=":1">{{Cite web |title=Glossary |url=https://docs.python.org/3/glossary.html |access-date=2024-02-07 |website=Python Documentation |language=en}}</ref><blockquote>An idea or piece of code which closely follows the most common idioms of the Python language, rather than implementing code using concepts common to other languages. For example, a common idiom in Python is to loop over all elements of an iterable using a <code>for</code> statement. Many other languages don’t have this type of construct, so people unfamiliar with Python sometimes use a numerical counter instead:
<syntaxhighlight lang="python">
for i in range(len(food)):
|