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">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>