Coming from Perl

Ben Finney bignose+hates-spam at
Thu Sep 13 03:11:56 CEST 2007

Amer Neely <perl4hire at> writes:

> print <<EndHTML;
> <html>
> <body>
> Hello
> </body>
> </html>

The equivalent in Python would be::

    print """

You can even use Python's standard textwrap module to indent your code

    import textwrap

    def foo(bar):
        if baz:
            print textwrap.dedent("""

The 'textwrap.dedent' function strips *common* leading whitespace from
all lines in the string, so in the above example the resulting string
will be as though the original string were typed flush to the left

See 'help(textwrap.dedent)' for what that function does, or read it
online <URL:>.

 \            "Madness is rare in individuals, but in groups, parties, |
  `\         nations and ages it is the rule."  -- Friedrich Nietzsche |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list