PEP 8 and extraneous whitespace

Ben Finney ben+python at
Sun Jul 31 09:56:53 CEST 2011

"OKB (not okblacke)" <brenNOSPAMbarn at> writes:

>     	Yeah, what I'm suggesting as the cleanest way is to simply make it 
> all one long string literal, which is wrapped by the editor to the 
> proper indentation point.  I can't show this in a newgroup post, but 
> it'd be like:
> def somefunc():
>     	if someCondition():
>     	    	"Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
> Fusce fermentum posuere mi eget molestie. Nulla facilisi. Curabitur et 
> ultrices massa."
> . . . except that the wrapped lines of the lorem ipsum would all line up 
> at the same level as the open quote.  This is clean because you get to 
> type it exactly as you wanted it.  You don't need to include extraneous 
> whitespice to get it to line up or wrap in your editor, and you also 
> don't need to choose the wrap points to put in extra quotes, as in your 
> example.  The irritating thing about doing it your way is that if you 
> later change the text and it rewraps, you have to move your quote
> marks.

You can have the text indented and wrapped how you like it, then remove
the leading whitespace at run-time with ‘textwrap.dedent’

 \        “Sane people have an appropriate perspective on the relative |
  `\     importance of foodstuffs and human beings. Crazy people can't |
_o__)                 tell the difference.” —Paul Z. Myers, 2010-04-18 |
Ben Finney

More information about the Python-list mailing list