What is the best way to print the usage string ?

BartlebyScrivener rpdooling at gmail.com
Thu Aug 3 12:33:05 EDT 2006


Leonel Gayard wrote:
>
> Notice that the string messes the indentation in my script. The
> indentation is correct, and if the script is invoked without
> arguments, the usage string is printed correctly.
>
> Now, how can I achieve the same result while keeping a clean
> indentation ? How is this done in python world ? In C, I would do
> this:

> The whitespace at the beginning of the string helps me keep the
> indentation clean, and the construct "a" "b" is syntactic sugar that
> allows me to create a large string without concatenating them at
> runtime.
>
> How can I get this in Python ?

Not sure exactly what you are after, but it sounds like you need the
textwrap module:

http://docs.python.org/lib/module-textwrap.html

Or look at string formatting opeartions

http://docs.python.org/lib/typesseq-strings.html

rd

:




More information about the Python-list mailing list