on-internet
← Community

Quoting long strings without newlines in Python

Stack Overflow ·

I am trying to write a long string in Python that gets displayed as the help item of an OptParser option. In my source code .py file, I'd like to place newlines so that my code doesn't spend new lines. However, I don't want those newlines to affect how that string is displayed when the code is run. For example, I want to write: parser.add_option("--my-option", dest="my_option", nargs=2, default=None, help='''Here is a long description of my option. It does many things but I want the shell to decide how to display this explanation. However, I want newlines in this string.''') the above way of d

Comments

Sign in or sign up to comment and upvote.

No comments yet.