<div>This has been discussed a few times in the past.</div><div><br></div><a href="http://mail.python.org/pipermail/python-ideas/2011-May/010207.html">http://mail.python.org/pipermail/python-ideas/2011-May/010207.html</a> triple-quoted strings and indendation<div>

<a href="http://mail.python.org/pipermail/python-ideas/2010-November/008589.html">http://mail.python.org/pipermail/python-ideas/2010-November/008589.html</a>  Multi-line strings that respect indentation</div><div><br></div>

<div><div><font face="arial, helvetica, sans-serif">--- Bruce</font><div><font face="arial, helvetica, sans-serif">Follow me: <a href="http://www.twitter.com/Vroo" target="_blank">http://www.twitter.com/Vroo</a> <a href="http://www.vroospeak.com" target="_blank">http://www.vroospeak.com</a></font></div>

<div><font face="arial, helvetica, sans-serif"><br></font></div><br>
<br><br><div class="gmail_quote">On Tue, Aug 16, 2011 at 2:33 PM, Michael Foord <span dir="ltr"><<a href="mailto:fuzzyman@gmail.com">fuzzyman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hello all,<br><br>I'm sure this will be shot down [1], but it annoys me often enough that I'm going to suggest it anyway. :-)<br><br>A recent tweet of Raymond's reminded me how useful textwrap.dedent() is for dedenting triple quoted strings in code blocks:<br>


<br>def function():<br>    this_string = textwrap.dedent("""\<br>        Here is some indented text.<br>        that dedent will handle for us."""<br>    )<br><br>Unfortunately that doesn't work for docstrings as they must be string literals. It is compounded by the fact that you can't even create the docstring for a class and manually assign it later. (Why not? But that's another issue...)<br>


<br>How about *another* string prefix for dedented strings:<br><br>class Thing(object):<br>    d"""<br>    This text will be,<br>    nicely dedented,<br>    thank you very much.<br>    """"<br>


<br>All the best,<br><br>Michael Foord<br><br>[1] Because of the -100 rule as much as anything else, which applies doubly to features requiring new syntax<br><a href="https://blogs.msdn.com/b/ericgu/archive/2004/01/12/57985.aspx" target="_blank">https://blogs.msdn.com/b/ericgu/archive/2004/01/12/57985.aspx</a><br clear="all">


<br>-- <br><pre cols="72"><a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a><br><br>May you do good and not evil<br>May you find forgiveness for yourself and forgive others<br>May you share freely, never taking more than you give.<br>


-- the sqlite blessing <a href="http://www.sqlite.org/different.html" target="_blank">http://www.sqlite.org/different.html</a></pre>
<br>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
<br></blockquote></div><br></div></div>