How to escape escape?

Sean Blakey sblakey at freei.com
Wed Apr 12 20:21:47 EDT 2000


On 12 Apr, Larry Gantz wrote:
> I'm new to the snake.
> I think I would like to be able to turn off and on the escape character
> processing so the snake would perform escape processing when I want it.
> 
> It seems that Python always has escape processing.
> 
> Thanks for any help.
> 
> 
I am not sure what you want, but you have two options in this wonderful
language named after insane comedians (cover art on documentation
notwithstanding):
You can use repr() or `` to get the representation of an escape
character.
>>> repr('spam\n')
"'spam\\012'"
Or you can use raw string (precede the quotation mark with the letter
r).
>> r'spam\n'
'spam\\n'
-- 

Sean Blakey
FreeInternet.com
sblakey at freei.com
(253)796-6500x1025





More information about the Python-list mailing list