multiline snippets with triple quotes

gohaku gohaku at earthlink.net
Fri Aug 13 04:08:25 CEST 2004


On Aug 12, 2004, at 4:06 PM, Christopher T King wrote:

> The textwrap.dedent() function is provided for just this purpose:
>
>  from textwrap import dedent
>
>  if output == html:
>      snip =  dedent('''\
>                      <html>
>                      <head><title>Hello, World</title></head>
>                      <body bgcolor="aqua"><h1>What's up?</h1>
>                      </html>''')
>  else:
>      snip = 'Hello!'
Can dedent capture indents or tabs also...
I noticed that if I do the following:
snip = '''<html>blah blah
			</html>'''
Tabs are included with snip.

Is there a heredocs (don't know why it's called that) equivalent in 
Python?

Thanks in advance.




More information about the Python-list mailing list