Re: [Tutor] wierd replace problem

2010-09-14 Thread Alan Gauld
"Steven D'Aprano" wrote OK,. Thats replacing a double slash in the data Er, surely not... I think you've confused backslashes and forward slashes. Or something. '\\' is a single backslash, not a double, because the first backslash is the escape character. A double backslash can be writt

Re: [Tutor] wierd replace problem

2010-09-14 Thread Steven D'Aprano
On Tue, 14 Sep 2010 03:28:46 am Alan Gauld wrote: > "Roelof Wobben" wrote > > > 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. > > OK,. Thats replacing a double slash i

Re: [Tutor] wierd replace problem

2010-09-13 Thread Steven D'Aprano
On Tue, 14 Sep 2010 09:08:24 am Joel Goldstick wrote: > On Mon, Sep 13, 2010 at 6:41 PM, Steven D'Aprano wrote: > > On Tue, 14 Sep 2010 04:18:36 am Joel Goldstick wrote: > > > How about using str.split() to put words in a list, then run > > > strip() over each word with the required characters to

Re: [Tutor] wierd replace problem

2010-09-13 Thread Joel Goldstick
On Mon, Sep 13, 2010 at 6:41 PM, Steven D'Aprano wrote: > On Tue, 14 Sep 2010 04:18:36 am Joel Goldstick wrote: > > > How about using str.split() to put words in a list, then run strip() > > over each word with the required characters to be removed ('`") > > > Doesn't work. strip() only removes ch

Re: [Tutor] wierd replace problem

2010-09-13 Thread Steven D'Aprano
On Tue, 14 Sep 2010 04:18:36 am Joel Goldstick wrote: > How about using str.split() to put words in a list, then run strip() > over each word with the required characters to be removed ('`") Doesn't work. strip() only removes characters at the beginning and end of the word, not in the middle:

Re: [Tutor] wierd replace problem

2010-09-13 Thread Joel Goldstick
On Mon, Sep 13, 2010 at 2:08 PM, bob gailer wrote: > On 9/13/2010 1:50 PM, Roelof Wobben wrote: > > [snip] > > hello Alan, >> >> Your right. Then it prints like this "'tis >> Which is not right. It must be tis. >> So the replace does not what it supposed to do. >> >> Sorry but I am now more co

Re: [Tutor] wierd replace problem

2010-09-13 Thread bob gailer
On 9/13/2010 1:50 PM, Roelof Wobben wrote: [snip] hello Alan, Your right. Then it prints like this "'tis Which is not right. It must be tis. So the replace does not what it supposed to do. Sorry but I am now more confused. After discovering no \ in the text file now you seem to have have a n

Re: [Tutor] wierd replace problem

2010-09-13 Thread Roelof Wobben
> To: tutor@python.org > From: alan.ga...@btinternet.com > Date: Mon, 13 Sep 2010 18:28:46 +0100 > Subject: Re: [Tutor] wierd replace problem > > > "Roelof Wobben" wrote > >> Now I want to get rid of th

Re: [Tutor] wierd replace problem

2010-09-13 Thread bob gailer
On 9/13/2010 12:58 PM, Roelof Wobben wrote: The orginal text can be found here : http://openbookproject.net/thinkcs/python/english2e/resources/ch10/alice_in_wonderland.txt There are no \ in that text! -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] wierd replace problem

2010-09-13 Thread Alan Gauld
"Roelof Wobben" wrote 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. OK,. Thats replacing a double slash in the data for line in file: line2 = line.replace ("\\","")

Re: [Tutor] wierd replace problem

2010-09-13 Thread Roelof Wobben
> From: rwob...@hotmail.com > To: tutor@python.org > Date: Mon, 13 Sep 2010 16:46:09 + > Subject: [Tutor] wierd replace problem > > > > > >> From: rwob...@hotmail.com >>

[Tutor] wierd replace problem

2010-09-13 Thread Roelof Wobben
> From: rwob...@hotmail.com > To: joel.goldst...@gmail.com > Subject: RE: [Tutor] wierd replace problem > Date: Mon, 13 Sep 2010 16:45:28 + > > > > > >> Date: Mon, 13 Sep 2010 12

Re: [Tutor] wierd replace problem

2010-09-13 Thread Joel Goldstick
On Mon, Sep 13, 2010 at 12:37 PM, Roelof Wobben wrote: > > > > > Date: Mon, 13 Sep 2010 12:17:47 -0400 > From: mich...@trollope.org > To: tutor@python.org > Subject: Re: [Tutor] wierd replace problem > > > On Mon, Sep 13,

Re: [Tutor] wierd replace problem

2010-09-13 Thread Roelof Wobben
Date: Mon, 13 Sep 2010 12:17:47 -0400 From: mich...@trollope.org To: tutor@python.org Subject: Re: [Tutor] wierd replace problem On Mon, Sep 13, 2010 at 12:19:23PM +, Roelof Wobben wrote: > > Hello, > > I have this string called t

Re: [Tutor] wierd replace problem

2010-09-13 Thread Michael Powe
On Mon, Sep 13, 2010 at 12:19:23PM +, 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 e

[Tutor] wierd replace problem

2010-09-13 Thread Roelof Wobben
> From: rwob...@hotmail.com > To: bgai...@gmail.com > Subject: RE: [Tutor] wierd replace problem > Date: Mon, 13 Sep 2010 15:19:12 + > > > > > >> Date: Mon, 13 Sep

Re: [Tutor] wierd replace problem

2010-09-13 Thread bob gailer
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.

Re: [Tutor] wierd replace problem

2010-09-13 Thread Michael Powe
Hello, In your script, you need to escape each backslash, in order to have it come out correctly to the interpreter. IOW, in the shell, '\\' is what is being processed. But in your script, you want to send '\\' to the shell, and in order to do that, you have to escape each backslash, or ''.

[Tutor] wierd replace problem

2010-09-13 Thread Roelof Wobben
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 progr