RFC PEP candidate: q'<delim>'quoted<delim> ?

Joshua Macy l0819m0v0smfm001 at sneakemail.com
Thu Mar 7 23:57:10 EST 2002


Greg Ewing wrote:

> I have another idea that doesn't suffer from that
> problem.
> 
>   def string my_string:
>     This is a free-form string constant. Its value consists
>     of all the text at this indentation level, verbatim,
>     with the indentation stripped off. It can contain
>     ', ", ''', """, \ or any other characters.
> 
> 


But then you have to indent everything in the text to that level, which 
isn't quite the same as cut-and-paste arbitrary text any more.  Granted, 
it's not hard to do with a good editor, but neither is escaping a 
whatever triple quotes you might find in the text (even Notepad can do 
that).

For that matter, the PEPs to make Python more unforgiving of what's 
contained in strings (only valid declared encodings or binary as octal 
escape sequences) seem to be advancing rapidly, so schemes for stuffing 
more arbitrary and unexamined junk into the source code seem to be 
heading in the wrong direction.

I guess I don't really see the motivation for the proposed feature.  If 
triple quoting isn't sufficient, I'd take that as a sign that the 
material should be a separate data file...it's not like Python makes it 
hard to read an external file into a string.

Joshua




More information about the Python-list mailing list