Is there any way to make repr(aString) use double quotes?
Mike C. Fletcher
mcfletch at rogers.com
Tue Apr 8 15:19:29 EDT 2003
Lulu of the Lotus-Eaters wrote:
>tweedgeezer at hotmail.com (Jeremy Fincher) wrote previously:
>|If it's not, then is it possible to achieve the same thing (everything
>|escaped properly, etc.) through other means?
>
>It's not beautiful, but this does what you want:
>
> '"%s"' % repr(aString)[1:-1]
>
>
Except when there's a " character in the string ;) .
def SFString_vrmlstr( value, lineariser=None):
"""Convert the given value to a VRML97 representation"""
return '"%s"'%(
'\\"'.join(
'\\\\'.join(
value.split('\\')
).split('"')
)
)
But that doesn't do any escaping of characters (e.g. \xff), so there's
more to be done :) ,
Mike
More information about the Python-list
mailing list