Subject line with smtplib.sendmail()

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Mar 21 01:56:29 CET 2007


"Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> writes:

> 	Perhaps you are using an """indented
> 	triple quoted
> 	string""" ?
>
> The indentation goes into the string itself. You may use a global
> (module) constant to hold the string, by example.

Rather than letting technical issues dictate where to place your code,
you can keep the indentation for code readability and remove it when
the data is processed::

    >>> import textwrap
    >>> def get_text():
    ...     raw_text = """\
    ...         Blah blah
    ...         spam eggs spam
    ...         """
    ...     text = textwrap.dedent(raw_text)
    ...     return text
    ...
    >>> foo = get_text()
    >>> print foo
    Blah blah
    spam eggs spam

    >>>

-- 
 \        "Somebody told me how frightening it was how much topsoil we |
  `\   are losing each year, but I told that story around the campfire |
_o__)                          and nobody got scared."  -- Jack Handey |
Ben Finney




More information about the Python-list mailing list