On Thursday 14 April 2005 02:03 am, Dan wrote: > If you use triple quotes to define a string, then the newlines are > implicitly included. This is a very nice feature. But if you're > inside a function or statement, then you'll want the string to be > positioned along that indentation. And the consequences of this is > that the string will include those indentations. > [...] > But that's just ugly.
Yeah, it's definitely a wart. So much so that recent Python distributions include a function to fix it: >>> from textwrap import dedent >>> string_block = dedent(""" ... This string will have the leading ... spaces removed so that it doesn't ... have to break up the indenting. ... """) >>> string_block "\nThis string will have the leading\nspaces removed so that it doesn't\nhave to break up the indenting.\n" >>> print string_block This string will have the leading spaces removed so that it doesn't have to break up the indenting. -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com -- http://mail.python.org/mailman/listinfo/python-list