This PEP describes an interpretation of multiline string constants
for Python. It suggests stripping spaces after newlines and
stripping a newline if it is first character after an opening
This PEP proposes an interpretation of multiline string constants
in Python. Currently, the value of string constant is all the
text between quotations, maybe with escape sequences substituted,
return "This is \
'This is \tstring'
This PEP suggest two things
- ignore the first character after opening quotation, if it is
- second: ignore in string constants all spaces and tabs up to
first non-whitespace character, but no more then current
After applying this, previous program will print:
'This is string'
To get this result, previous programs could be rewritten for
current Python as (note, this gives the same result with new
"This is \
Or stripping can be done with library routines at runtime (as
pydoc does), but this decreases program readability.
I'll say nothing about CPython, Jython or Python.NET.
In original Python, there is no info about the current indentation
(in spaces) at compile time, so space and tab stripping should be
done at parse time. Currently no flags can be passed to the
parser in program text (like from __future__ import xxx). I
suggest enabling or disabling of this feature at Python compile
time depending of CPP flag Py_PARSE_MULTILINE_STRINGS.
New interpretation of string constants can be implemented with flags
'i' and 'o' to string constants, like
SELECT * FROM car
WHERE model = 'i525'
""" is in new style,
o"""SELECT * FROM employee
WHERE birth < 1982
""" is in old style, and
SELECT employee.name, car.name, car.price FROM employee, car
WHERE employee.salary * 36 > car.price
""" is in new style after Python-x.y.z and in old style otherwise.
Also this feature can be disabled if string is raw, i.e. if flag 'r'
This document has been placed in the Public Domain.