Triple quoted string in exec function ?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Dec 30 19:00:24 EST 2008


En Tue, 30 Dec 2008 18:16:39 -0200, Stef Mientki <stef.mientki at gmail.com>  
escribió:
> ibpet11 at gmail.com wrote:

>> the message Steven sent you is ok to explain how to work with triple
>> quote
>>
> Yes, but not to work around my problem.
> I guess I've to remove all triple quoted strings from my code.

Why so?
You only have to avoid repeating the *same* kind of triple quotes inside a  
triple quoted string literal. But you are free to use any other  
combination of ' and ", even include the surrounding triple quotes escape  
inside (escaping them with \)

>>> x = """This is line 'one'.
... ''line "two" starts '''here
... and this is line three''
... this last line contains \"\"\" too"""
>>> print x
This is line 'one'.
''line "two" starts '''here
and this is line three''
this last line contains """ too

With so much freedom I can't imagine what prevents you from using triple  
quoted strings.

-- 
Gabriel Genellina




More information about the Python-list mailing list