Embedded 'C' problem?

Bengt Richter bokr at accessone.com
Sun Jun 3 15:24:32 EDT 2001


On 3 Jun 2001 01:11:03 -0700, samschul at pacbell.net (Samuel
Schulenburg) wrote:
[...]
>I would like to give a big thanks to your post. You hit the solution
>right on the head. I ennded up escaping  \"  \'  \\ and that fixed the
>problem.
Glad it worked out. Actually what prompted this is your \' above.
UIAM you only need to escape the kind of quote you're quoting with.
I think you should have been ok with just \" and \\ since you were
quoting with """. I'm not saying \' will hurt anything, just wondering
if you actually needed it.

 >>> print '"',"'","\"",'\''
 " ' " '

Triple quotes give you more freedom, which is handy for writing
__doc__ strings including newlines etc., but you still have to use an
escape to quote the same kind of triple quote as you're quoting with:

 >>> print '''"""''',"""'''""","""""\"""",'''''\''''
 """ ''' """ '''

I.e., you just have to avoid three in a row, which you can do
by escaping the third. But with unknown input it's easier just
to escape all the quotes matching your outside quotes.

Your application did seem a little odd, but I suppose it was
a test thing ;-)




More information about the Python-list mailing list