Gregory P. Smith <g...@krypto.org> added the comment:
I expect several phases here: (1) add a .dedent() method to str (and bytes?) - behaviors to consider mirroring are textwrap.dedent() and inspect.cleandoc(). Given their utility and similarities, it makes sense to offer both behaviors; behavior could be selected by a kwarg passed to the method. https://docs.python.org/3/library/textwrap.html#textwrap.dedent https://docs.python.org/3/library/inspect.html#inspect.cleandoc (2a) Ponder the d" prefix - but in general I expect sentiment to be against yet another letter prefix. They aren't pretty. This would need a PEP. Someone would need to champion it. (2b) Ponder making cleandoc dedenting automatic for docstrings. This would be enabled on a per-file basis via a `from __future__ import docstring_dedent` or similar as Serhiy suggested. No prefix letter required. Several releases later we could consider making it the default. This will also need needs a PEP. (3) Optimizations when .dedent() is called on a constant? Nice to have, But I suggest we land (1) first as its own base implementation PR. Then consider the follow-ons in parallel. I believe the current patch contains (1)+(3) right now. If so we should simplify it to (1) and make (3) am immediate followup as saving the runtime cost and data space is worthwhile. Ultimate end state: probably 1+2b+3, but even 1+3 or 1+2b is a nice win. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36906> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com