<br>
<br><br><div class="gmail_quote">On Fri, May 13, 2011 at 9:14 AM, Stephen J. Turnbull <span dir="ltr"><<a href="mailto:stephen@xemacs.org">stephen@xemacs.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">Matthias Lehmann writes:<br> > Well, it's not the fault of textwrap.dedent, that is has no notion of<br>
 > the indendation-level of its argument. As far as I know, that is<br>
 > something, only the parser knows (not that I know anything about the<br>
 > Python parser).<br>
<br>
</div>Oh, I thought you were referring to the indentation within the string<br>
(on the first line), not where the string begins.  Sorry!<br>
<br>
But I think there's real trouble here, because there are different<br>
styles of indentation, as we've seen.  You'd have to enforce one for<br>
triple-quoted strings, but that's likely to conflict with many<br>
developers' ideas about the matter.  That's really not something the<br>
parser should be doing ....</blockquote><div><br></div><div>If this feature were to be added, we would surely want to ignore the indentation on the first line regardless of the previous line since it shouldn't depend on whether or not I use two or four space indents:</div>

<div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">    fun_func(-"""</font></div><div><font class="Apple-style-span" face="'courier new', monospace">        multiple</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">        lines</font></div><div><font class="Apple-style-span" face="'courier new', monospace">        """)</font></div><div>

<font class="Apple-style-span" face="'courier new', monospace">#   ^^^^ don't want these spaces in my string</font></div><div><br></div><div>but unless we force people to follow the convention that you must have a line break after the opening """ we would need to ignore indentation starting with the second line for people who use this style:</div>

<div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">    fun_func(-"""foo</font></div><div><font class="Apple-style-span" face="'courier new', monospace">                 bar</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">                 more""")</font></div><div><br></div><div>Now personally, I'd probably follow that first style but if this were a language feature I wouldn't think it should only work for one style. Here's pseudo-code:</div>

<div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div class="gmail_quote"><div><font class="Apple-style-span" face="'courier new', monospace">if s[0] == '\n':  # style = first case above</font></div>

</div><div class="gmail_quote"><div><font class="Apple-style-span" face="'courier new', monospace">    strip first character and strip indentation starting with first line</font></div></div><div class="gmail_quote">

<div><font class="Apple-style-span" face="'courier new', monospace">else if s[0] == ' ':</font></div></div><div class="gmail_quote"><div><font class="Apple-style-span" face="'courier new', monospace">    strip indentation starting with first line   # style = """\</font></div>

</div><div class="gmail_quote"><div><font class="Apple-style-span" face="'courier new', monospace">else:</font></div></div><div class="gmail_quote"><div><font class="Apple-style-span" face="'courier new', monospace">    strip indentation starting with second line  # style = second case above</font></div>

</div></blockquote><div class="gmail_quote"><div><br></div><div>--- Bruce</div><div><br></div></div>