[Python-ideas] Syntax for dedented strings
Ben Finney
ben+python at benfinney.id.au
Tue Aug 16 23:58:36 CEST 2011
Michael Foord <fuzzyman at gmail.com> writes:
> How about *another* string prefix for dedented strings:
>
> class Thing(object):
> d"""
> This text will be,
> nicely dedented,
> thank you very much.
> """"
class Thing(object):
""" This literal string contains leading and trailing whitespace.
It also is indented. But none of that will show up when the
docstring is processed and presented to the user.
Because it is a docstring that conforms to PEP 257, the
indentation will be handled properly by PEP-257 conformant
docstring processors.
<http://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation>_
gives the specification for how indentation shall be handled by
code that processes Python docstrings.
The programmer inspecting the value of ‘__doc__’ will still see
the leading, trailing, and indenting whitespace; but the
programmer doing so isn't the recipient of the docstring as a
docstring.
So I don't see what problem there is to be solved.
"""
pass
--
\ “Guaranteed to work throughout its useful life.” —packaging for |
`\ clockwork toy, Hong Kong |
_o__) |
Ben Finney
More information about the Python-ideas
mailing list