[Python-ideas] Syntax for dedented strings

Michael Foord fuzzyman at gmail.com
Wed Aug 17 00:43:29 CEST 2011


On 16 August 2011 22:58, Ben Finney <ben+python at benfinney.id.au> wrote:

> 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 place I'm concerned about is the interactive interpreter, virtually the
only place I look at docstrings that isn't directly in the source code (or
pre-processed by a doc tool - but I don't care about that).

Michael



>
>        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
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 

http://www.voidspace.org.uk/

May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110816/884e1994/attachment.html>


More information about the Python-ideas mailing list