Hi Luke,

> Is there a way to preserve the readability of the code and have
> printed text from indented blocks, say, nested conditionals, appear
> flush at left, not printed exactly where I've written them in the
> script?

you can use the textwrap module for this.

>>> from textwrap import dedent
>>> print dedent("""\
...     some
...     indented
...     text""")
some
indented
text
>>> 

"dedent" is a utility function of the textwrap module that trims every
line by an equal amount. The trick here is the backslash so that the
first line doesn't count. The "fill" and "wrap" functions of textwrap
might also interest you:
http://www.python.org/doc/2.3.5/lib/module-textwrap.html.

Cheers, Michael
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to