[Python-ideas] triple-quoted strings and indendation

Stephen J. Turnbull stephen at xemacs.org
Fri May 13 18:14:29 CEST 2011


Matthias Lehmann writes:
 > Am 13.05.2011 15:13, schrieb Stephen J. Turnbull:
 > > Matthias Lehmann writes:
 > >   >  >  Wild idea: make the unary + operator on strings do
 > >   >  >  textwrap.dedent() on them.
 > >   >  >
 > >   >  The disadvantage compared to a string flag is, that this unary operator
 > >   >  has no knowledge of the current indendation level within the code
 > >
 > > But then your complaint is against text.dedent, not against Python
 > > syntax.  (That's no reason you can't have 2 complaints, of course.)
 > 
 > Well, it's not the fault of textwrap.dedent, that is has no notion of 
 > the indendation-level of its argument. As far as I know, that is 
 > something, only the parser knows (not that I know anything about the 
 > Python parser).

Oh, I thought you were referring to the indentation within the string
(on the first line), not where the string begins.  Sorry!

But I think there's real trouble here, because there are different
styles of indentation, as we've seen.  You'd have to enforce one for
triple-quoted strings, but that's likely to conflict with many
developers' ideas about the matter.  That's really not something the
parser should be doing ....





More information about the Python-ideas mailing list