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

2008-12-27 Thread Stef Mientki
Steven D'Aprano wrote: On Sat, 27 Dec 2008 01:41:40 +0100, Stef Mientki wrote: Sorry if I offended someone, that was certainly not my intention. And I guess you will be surprised, if I tell you, I don't (want) to understand any bit of the above code ;-) Come on, the home computer was

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

2008-12-27 Thread Martin
2008/12/27 Stef Mientki stef.mien...@gmail.com: Steven D'Aprano wrote: No, that only makes it even more confusing. What does Moore's Law have to do with your willful ignorance about the existence of human languages other than English? Nothing. I even don't (want to) see what bits / bytes /

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

2008-12-26 Thread Stef Mientki
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\nPCWrite =

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

2008-12-26 Thread John Machin
On Dec 27, 12:05 am, Stef Mientki stef.mien...@gmail.com wrote: Yep, chr(254), because it's not in the human range of characters and it's accepted by windows ini-files. import unicodedata as ucd for i in (0,1,2,3,4,7,8): ...s = chr(254) ...enc = 'cp125' + str(i) ...try: ...

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

2008-12-26 Thread Stef Mientki
John Machin wrote: On Dec 27, 12:05 am, Stef Mientki stef.mien...@gmail.com wrote: Yep, chr(254), because it's not in the human range of characters and it's accepted by windows ini-files. import unicodedata as ucd for i in (0,1,2,3,4,7,8): ...s = chr(254) ...enc

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

2008-12-26 Thread Steven D'Aprano
On Sat, 27 Dec 2008 01:41:40 +0100, Stef Mientki wrote: Sorry if I offended someone, that was certainly not my intention. And I guess you will be surprised, if I tell you, I don't (want) to understand any bit of the above code ;-) Come on, the home computer was invented about 1980. If we look

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

2008-12-25 Thread Stef Mientki
hello, Is there a function to remove escape characters from a string ? (preferable all escape characters except \n). thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list

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

2008-12-25 Thread James Stroud
Stef Mientki wrote: hello, Is there a function to remove escape characters from a string ? (preferable all escape characters except \n). thanks, Stef import string WANTED = string.printable[:-5] + \n def descape(s, w=WANTED): return .join(c for c in s if c in w) James -- James

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

2008-12-25 Thread Jeremiah Dodds
On Thu, Dec 25, 2008 at 7:02 AM, James Stroud jstr...@mbi.ucla.edu wrote: Stef Mientki wrote: hello, Is there a function to remove escape characters from a string ? (preferable all escape characters except \n). thanks, Stef import string test = 'this\r is a test\t yeah\n' for c

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

2008-12-25 Thread John Machin
On Dec 25, 9:00 pm, Stef Mientki stef.mien...@gmail.com wrote: hello, Is there a function to remove escape characters from a string ? (preferable all escape characters except \n). \n is not what most people would call an escape character. The \ is what most people would call an escape

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

2008-12-25 Thread Steven D'Aprano
On Thu, 25 Dec 2008 11:00:18 +0100, Stef Mientki wrote: hello, Is there a function to remove escape characters from a string ? (preferable all escape characters except \n). Can you explain what you mean? I can think of at least four alternatives: (1) Remove literal escape sequences

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

2008-12-25 Thread Stef Mientki
Steven D'Aprano wrote: On Thu, 25 Dec 2008 11:00:18 +0100, Stef Mientki wrote: hello, Is there a function to remove escape characters from a string ? (preferable all escape characters except \n). Can you explain what you mean? I can think of at least four alternatives: I have

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

2008-12-25 Thread John Machin
On Dec 26, 8:53 am, Stef Mientki stef.mien...@gmail.com wrote: Steven D'Aprano wrote: On Thu, 25 Dec 2008 11:00:18 +0100, Stef Mientki wrote: hello, Is there a function to remove escape characters from a string ? (preferable all escape characters except \n). Can you explain what you