Triple-quoted strings hath not the Python-nature

Mel mwilson at the-wire.com
Mon Oct 27 00:23:11 EDT 2008


Lawrence D'Oliveiro wrote:

> In message <010fec39$0$20657$c3e8da3 at news.astraweb.com>, Steven D'Aprano
> wrote:
> 
>> I disagree. Triple-quoted strings are exactly the same as other strings:
>> they capture *exactly* what you put in them ...
> 
> But that conflicts with the use of whitespace for indentation rules. Other
> languages are freeform, and have strings that include whitespace as
> significant.
> 
> In short, if whitespace is significant outside a string, then it shouldn't
> be significant inside. And vice versa.

I think the rule is that whitespace leading a statement is significant. 
Whitespace inside a statement isn't.  For example, whitespace inside a pair
of parentheses isn't significant:

Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> if True:
...     print (
... 'a b d c d')
...
a b d c d
>>>





More information about the Python-list mailing list