setrtalking.blogg.se

Three principles from zen of python
Three principles from zen of python












three principles from zen of python
  1. THREE PRINCIPLES FROM ZEN OF PYTHON HOW TO
  2. THREE PRINCIPLES FROM ZEN OF PYTHON SOFTWARE
  3. THREE PRINCIPLES FROM ZEN OF PYTHON CODE

What about Zen principle #3: that simple is better than complex? In 2015 Python added an optional code syntax for providing “hint” about the type of a variable.(Neugebauer provides the example of a function which once returned a value, suddenly modified into returning a list!) Yet this isn’t obvious from Python’s decorator syntax, which Neugebauer says clearly violates principle #2: “Explicit is better than implicit.”Instead, he sees Python’s decorators bringing dreaded “implicit behavior” to the very act of defining a function - since what the function does ultimately depends, entirely, on what its decorator does. While some argue those decorators “modify” a function’s behavior, Neugebauer’s talk counters that they flat-out change functions, discarding the original entirely while replacing it with something completely different.

three principles from zen of python three principles from zen of python

And this seems to violate Zen of Python principle #7: “Readability counts.” Neugebauer’s talk explores a scenario where Python’s function-modifying decorators could make longer code samples unreadable.“When I first spent time thinking about the Zen of Python, I thought they were rules,” Neugebauer said in his email, “until I eventually found the contradictions staring me in the face.”

THREE PRINCIPLES FROM ZEN OF PYTHON SOFTWARE

Neugebauer is also a former director and vice chair of the Python Software Foundation - and yet his talk’s description cautions that “even with prescriptive rules, writing ‘Good’ Python remains a subjective exercise.” “My biggest goal has been to get Python developers to start thinking critically about the qualities of their code,” Neugebauer said in an email interview last week, “rather than simply repeating lines from the Zen of Python to justify how they write their code.” At P圜ascades he subjected those principles to some informed contrarian scrutiny, providing his audience with compelling examples of contradictions.īut along the way there were also larger lessons about practicality, communities, and how programming languages grow… Yet Neugebauer warned his audience that while it’s easy to think there’s a “prescriptive” design philosophy that will always dictate the syntax for good Python code - there isn’t. Statements such as “If the implementation is hard to explain, it’s a bad idea.” Barry Warsaw, a software engineer on the Python Foundation team at LinkedIn, once even set them to music. That core developer said he’d once written a blog post - only to be told by his partner that he’d tried to justify two entirely different (and contradictory) style decisions.īut even more confounding: he’d found support for both styles in the canonical “ Zen of Python” principles that for over two decades have been cherished by the wider Python community.įirst released on a Python mailing list in 1999, the long-standing (but unofficial) “guiding principles” written by programmer Tim Peters seemed to capture the language’s philosophy in a series of 19 succinct aphorisms.

THREE PRINCIPLES FROM ZEN OF PYTHON HOW TO

A Python core developer thanked him for providing a framework for how to make choices about coding styles. Software engineer Christopher Neugebauer got a surprise after delivering a talk at the P圜ascades Python conference in Vancouver this March.














Three principles from zen of python