
On 01/04/2018 02:48, Steven D'Aprano wrote:
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.]
Can I suggest, rather than another string prefix, that will require the user to add the d flag to every string that they use, we consider a file scope dedent_multiline or auto_dedent import, possibly from __future__ or textwrap, that automatically applies the dedent function to all multiline strings in the file. This would reflect that, typically, a specific developer tends to want either all or no multi-line text strings dedented. It should have minimumal impact on the language, operate at compile time so be low overhead and avoid cluttering strings up. -- Steve (Gadget) Barnes Any opinions in this message are my personal opinions and do not reflect those of my employer. --- This email has been checked for viruses by AVG. http://www.avg.com