Indented multi-line strings
Dan Strohl
D.Strohl at F5.com
Fri Jun 1 10:36:15 EDT 2018
>
> I would prefer to remove the padding, like this:
>
> Test = """
> | Hello, this is a
> | Multiline indented
> |String
> """.outdent(padding='|')
>
> Or write it like this?
>
> Test = """| Hello, this is a
> | Multiline indented
> |String
> """.outdent(padding='|')
>
> Hmm, the sign of Zorro! :-)
>
> I'm starting to like outdent(), but that may be my TIMTOWTDIism speaking.
>
I can see both outdent(padding="|") and outdent(size=4) being useful in various cases. If this ends up being the recommendation, I would also suggest adding str.indent(), it evens out the methods and most of the time I use the textwrap functions it is either indent or outdent, so this would clean up those pieces.
So... how does one go about suggesting changes to the built in types? I could take a whack at the code for it, but my C skills are no where near what should probably be needed for something this close to the core of the language. I'm not sure if adding a couple of methods is a PEP type of thing.
Dan Strohl
More information about the Python-list
mailing list