[Python-Dev] Triple-quoted strings and indentation

Nick Coghlan ncoghlan at gmail.com
Wed Jul 6 14:32:36 CEST 2005

Andrew Durdin wrote:
> Here's the draft PEP I wrote up:

Well reasoned, and well written up IMO. In particular, being able to 
preserve all leading whitespace by the simple expedient of putting the 
closing triple quote in column zero and escaping the final newline is 
a nice feature.

However, while I prefer what you describe to Python's current 
behaviour, I am not yet convinced the backward compatibility pain is 
worth it. Adding yet-another-kind-of-string-literal (when we already 
have bytestrings on the horizon) is also unappealing.

Your readability examples are good, but the first two involve strings 
that should probably be module level constants (as Terry described) 
and the test case involving expected output is probably better handled 
using doctest, which has its own mechanism for handling indentation.

Raw and unicode string literals need to be mentioned in the PEP. Which 
literals would the reformatting apply to? All 3? Only standard and 
unicode, leaving raw strings alone?

You should research the reasons why PEP 295 [1] was rejected, and 
describe in the new PEP how it differs from PEP 295 (unfortunately PEP 
295 was not updated with the rationale for rejection, but this post 
[2] looks like Guido putting the final nail in its coffin).


[1] http://www.python.org/peps/pep-0295.html
[2] http://mail.python.org/pipermail/python-dev/2002-July/026969.html

Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list