[Python-ideas] Idea for new multi-line triple quote literal

Ben Finney ben+python at benfinney.id.au
Mon Jul 1 05:15:39 CEST 2013


nbv4 <nbvfour at gmail.com> writes:

> The tripple quote string literal is a great feature, but there is one 
> problem. When you use them, it forces you to break out of you're current 
> indentation which maks code look ugly.

We have the ‘textwrap.dedent’ function in the standard library. Here is
a StackOverflow answer that shows how it is used for exactly the
situation you describe <URL:http://stackoverflow.com/a/2504454/70157>.

> I propose a new way to define a triple back quote that woks the same
> way regular triple quotes work, but instead does some simple parsing
> of the data within the quotes to preserve the flow of the code.

−1. This problem already has a standard-library solution, it is not
common enough to need a change to the language syntax.

If anything, a ‘dedent’ method on strings would be good. But not adding
more complexities to syntax for this, please.

-- 
 \       “Following fashion and the status quo is easy. Thinking about |
  `\        your users' lives and creating something practical is much |
_o__)                                harder.” —Ryan Singer, 2008-07-09 |
Ben Finney



More information about the Python-ideas mailing list