What is the best way to print the usage string ?
Tony Nelson
*firstname*nlsnews at georgea*lastname*.com
Sat Aug 5 14:03:55 EDT 2006
In article <1154625685.027648.133500 at p79g2000cwp.googlegroups.com>,
"Simon Forman" <rogue_pedro at yahoo.com> wrote:
...
> Python also concatenates adjacent strings, but the "real" newlines
> between your strings will need to be escaped (otherwise, because the
> newlines are statement separators, you will have one print statement
> followed by string literals with the wrong indentation.)
>
> print "Usage: blah blah blah\n" \
> "Some more lines in the usage text\n" \
> "Some more lines here too."
>
> (Note that the final string literal newline is not needed since print
> will add one of it's own.)
One can also use parentheses:
print ( "Usage: blah blah blah\n"
"Some more lines in the usage text\n"
"Some more lines here too." )
The newlines in the string are still needed, but the ones escaping the
EOLs are not.
________________________________________________________________________
TonyN.:' *firstname*nlsnews at georgea*lastname*.com
' <http://www.georgeanelson.com/>
More information about the Python-list
mailing list