On Fri, Jun 1, 2018 at 7:05 AM, Peter J. Holzer <hjp-pyt...@hjp.at> wrote: > [Strange: I didn't get this mail through the list, only directly] > > On 2018-05-31 14:39:17 +0000, Dan Strohl wrote: >> The outdent method could look like: >> >> string.outdent(size=None) >> """ >> :param size : The number of spaces to remove from the beginning of >> each line in the string. Non space characters will not be >> removed. IF this is None, the number of characters in the first >> line of the string will be used. > > The default should be the minimum number of leading spaces on non-empty > lines, I think. This is compatible with PEP 257. And in fact it allows > all lines to start with whitespace if the string ends with a newline > (which is a weird dependency, but probably not much of a restriction in > practice).
Exactly. The default will be the most commonly used option when working with string literals; explicitly setting it is there if you need it, but won't be the normal way you do things. Either way, if attached to a string literal, with either no parameter or a literal integer, this would be a valid candidate for constant folding. (There's no way to monkeypatch or shadow anything.) At that point, we would have all the benefits of a new string literal type, with no syntactic changes, just the creation of the method. ChrisA -- https://mail.python.org/mailman/listinfo/python-list