[Python-ideas] Syntax for dedented strings
Steven D'Aprano
steve at pearwood.info
Wed Aug 17 01:36:51 CEST 2011
Michael Foord wrote:
> How about *another* string prefix for dedented strings:
>
> class Thing(object):
> d"""
> This text will be,
> nicely dedented,
> thank you very much.
> """"
I think you need to explain the problem being solved, and your
requirements, in a bit more detail here. As I understand it, the above
is equivalent to this:
class Thing(object):
"""
This text will be,
nicely dedented,
thank you very much.
"""
except that it looks indented in the source file. Compare that to the
usual practice:
class Thing(object):
"""
This text will be,
nicely dedented,
thank you very much.
"""
and the only difference is a bunch of leading spaces.
If all you do with the docstrings is read them with help() in the
interactive interpreter, why do you care about saving a few spaces?
help() calls pydoc, which does its own reformatting of the docstring.
Unless you regularly inspect instance.__doc__ by hand (not via help),
I'm not sure what you hope to accomplish here.
--
Steven
More information about the Python-ideas
mailing list