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

Bengt Richter bokr at oz.net
Fri Mar 8 18:37:37 EST 2002


On Fri, 08 Mar 2002 04:51:39 GMT, "Terry Reedy" <tejarex at yahoo.com> wrote:

>
>"Bengt Richter" <bokr at oz.net> wrote in message
>news:a6912n$jnt$0 at 216.39.172.122...
>> Sorry, I wasn't making clear an unspoken condition I really had in
>mind ;-)
>> I think (3) does follow (2) using the added explicit condition that
>the
>> text quotation is to be part of the source text of a program or
>module,
>> and the quoted text must not need to be changed or restricted to do
>it.
>
>With the added conditions, the logic works much better.
>
>...
>> The simplest practical example is wanting to use a paste operation
>> to insert arbitrary text into a program source without having to
>inspect
>> the text or modify it, yet be able to use it to define a string
>> with the exact raw text value.
>
>As Greg Ewing noted, you still have to scan the text with your method,
>so why not scan for triple quotes - which are *extremely* rare in any
>text except Python code and *quite* easy to spot (speaking for
>myself).  One can always use the interpreter to check also.  Write
>s='''\
><paste text here>
>'''
>and run or paste into interpreter.  If there is a ''' that one missed,
>there will almost certainly be a SyntaxError reported, with the line
>number.  One could also follow the definition of s with 'print
>s[:-100]' to see if entire quotation got included in assignment.
>
>For myself, I can hardly imagine wanting to incorparate gobs of
>someone else's text into my code.  If I did, I would want to look at
>it and/or isolate it in a separate module where it could be tested as
>above.  I would also feel free to modify it with escape codes if
>necessary.
>
I'd prefer to have a quick look and choose an easy delimiter and be done,
instead of all that testing to see if there were tricky \''' sequences
and whatnot, and then fussing with the content, which diff could then
no longer see as quivalent to the original.

Regards,
Bengt Richter




More information about the Python-list mailing list