The Python Apprentice
上QQ阅读APP看书,第一时间看更新

Moment of zen

The text in the following image Moment of zen: Practicality beats purity – Beautiful text strings, Rendered in literal form. Simple elegance:

Figure 2.1: Moment of zen: Practicality beats purity Moment of zen

At first sight support for both quoting styles seems to violate an important principle of Pythonic style. From the Zen of Python:

There should be one – and preferably only one – obvious way to do it.

In this case, however, another aphorism from the same source takes precedence:

Practicality beats purity

The utility of supporting two quoting styles is valued more highly than the alternative:a single quoting style combined with more frequent use of ugly escape sequences, which we'll encounter shortly.