[Python-ideas] Dart like multi line strings identation

Steven D'Aprano steve at pearwood.info
Sat Mar 31 21:48:07 EDT 2018


On Sun, Apr 01, 2018 at 02:20:16AM +0100, Rob Cliffe via Python-ideas wrote:

> >New unordered 'd' and 'D' prefixes, for 'dedent', applied to multiline 
> >strings only, would multiply the number of alternatives by about 5 and 
> >would require another rewrite of all code (Python or not) that parses 
> >Python code (such as in syntax colorizers).
>
> I think you're exaggerating the difficulty somewhat.  Multiplying the 
> number of alternatives by 5 is not the same thing as increasing the 
> complexity of code to parse it by 5.

Terry didn't say that it would increase the complexity of the code by a 
factor of five. He said it would multiply the number of alternatives by 
"about 5". There would be a significant increase in the complexity of 
the code too, but I wouldn't want to guess how much.

Starting with r and f prefixes, in both upper and lower case, we have:

4 single letter prefixes
(plus 2 more, u and U, that don't combine with others)
8 double letter prefixes

making 14 in total. Adding one more prefix, d|D, increases it to:

6 single letter prefixes
(plus 2 more, u and U)
24 double letter prefixes
48 triple letter prefixes

making 80 prefixes in total. Terry actually underestimated the explosion 
in prefixes: it is closer to six times more than five (but who is 
counting? apart from me *wink*)

[Aside: if we add a fourth, the total becomes 634 prefixes.]



-- 
Steve


More information about the Python-ideas mailing list