----------------------------------------
> From: rwob...@hotmail.com
> To: bgai...@gmail.com
> Subject: RE: [Tutor] wierd replace problem
> Date: Mon, 13 Sep 2010 15:19:12 +0000
>
>
>
>
> ----------------------------------------
>> Date: Mon, 13 Sep 2010 11:07:19 -0400
>> From: bgai...@gmail.com
>> To: tutor@python.org
>> Subject: Re: [Tutor] wierd replace problem
>>
>> On 9/13/2010 8:19 AM, Roelof Wobben wrote:
>>> Hello,
>>>
>>> I have this string called test with the contents of 'het is een wonder 
>>> \\TIS'
>>>
>>> Now I want to get rid of the \\ so I do this : test2 = test.replace ('\\', 
>>> '')
>>> And I get at the python prompt this answer : 'het is een wonder TIS'
>>> So that's right.
>>>
>>> Now I try the same in a IDE with this programm :
>>>
>>> woorden =[]
>>> letter_counts = {}
>>> file = open ('alice_in_wonderland.txt', 'r')
>>> for line in file:
>>> line2 = line.replace ("\\","")
>>> line3 = line2.lower()
>>> woorden = line3.split()
>>> for letter in woorden:
>>> letter_counts[letter] = letter_counts.get (letter, 0) + 1
>>> letter_items = letter_counts.items()
>>> letter_items.sort()
>>> print letter_items
>>>
>>> But now Im gettting this output :
>>>
>>> [('"\'tis', 1),
>>>
>>> Why does the \ stays here. It should have gone as the test in the python 
>>> prompt says.
>> I ran your program against a 1 line file containing 'het is een wonder
>> \\TIS'
>> The result I get is [('een', 1), ('het', 1), ('is', 1), ('tis', 1),
>> ('wonder', 1)]
>>
>> Dunno why you are getting a different result.
>>
>> Here is where using the debugger and going step by step can help. I have
>> no experience with the IDLE debugger. Perhaps others can offer advice on
>> that.
>>
>> --
>> Bob Gailer
>> 919-636-4239
>> Chapel Hill NC
>>
>> _______________________________________________
>> Tutor maillist - Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>

Hello everyone.

Chancing to (r\\, '') or (\\\\, '') did not help.

I know that there were more outcome. I would only let see that on the python 
prompt the \ is deleted and if I use Eclipse the / stays when I use the text 
from alice in wonderland.

 And im still wondering why this happens.
 Maybe put the text from alice into the python prompt and look what happens.

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

Reply via email to