Is there a function to remove escape characters from a string ?

Stef Mientki stef.mientki at
Fri Dec 26 14:05:15 CET 2008

>> I have the following kind of strings,
>> the funny "þ" is ASCII character 254, used as a separator character
> ASCII ends at 127. Just refer to it as chr(254).
note 1)
>> [FSM]
>> Counts = "1þ11þ16"     ==>   1,11,16
>> Init1 = "1þ\BCtrl"     ==>    1,Ctrl
>> State5 = "8þ\BJUMP_COMPL\b\n>PCWrite = 1\n>PCSource = 10"
>>          ==> 8, JUMP_COMPL\n>PCWrite = 1\n>PCSource = 10
> After making those substitutions, what are you going to do with it?
> Split it up into fields using the csv module or stuff.split(",") or
> some other DIY method? Is there a possibility that whoever "designed"
> that data format used chr(254) as a separator because the data fields
> contained "," sometimes and so "," could not be used as a separator?
Yep, chr(254), because it's not in the human range of characters
and it's accepted by windows ini-files.
>> Seeing and testing all your answers, with great solutions that I've
>> never seen before,
> As far as str methods and built-ins that work on str objects are
> concerned, there is no corpus of secret knowledge known only to a
> cabal of wizards; it's all in the manual, and you don't need special
> magical spectacles to see it :-)
note 2)
>> knowing nothing of escape sequences (I'm a windows guy ;-)
> Why do you think that whether or not you are a "windows guy" is
> relevant to knowing anything about escape sequences?
Just a windows guy,
or maybe better, "being a windows guy for many years",
windows users are wysiwyg users, they are not dealing with individual bits.
I personally left escape sequences and values of ASCII characters behind 
me more than 25 years ago.
And now maybe you might understand note 1) and note 2) .


More information about the Python-list mailing list