[Tutor] FW: wierd replace problem

Timo timomlists at gmail.com
Tue Sep 14 18:50:45 CEST 2010


On 14-09-10 17:44, Roelof Wobben wrote:
>>> 9 stripped_words = words.strip(".,!?'`\"- ();:")
>>>
>>>        
>>
>>      
> Hello Joel,
>
> Your solution works.
> Im getting grazy. I tried it two days with strip and get a eof error message and now no messages.
>    
Look at the backslash! It doesn't strip the backslash in the string, but 
it escapes the double quote following it.

I don't know how people can explain it any better.

You *do* see that this doesn't work, right?
 >>> s = "foo"bar"

So you can't do this either:
 >>> word.strip(",.!";:")

You need to escape the quote between the quotes:
 >>> word.strip(".,!\";:")

Timo

> Roelof
>
>
>    		 	   		
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>    



More information about the Tutor mailing list