Re: [Tutor] FW: wierd replace problem

2010-09-15 Thread Roelof Wobben
> Date: Tue, 14 Sep 2010 22:15:40 +0100 > From: wpr...@gmail.com > To: tutor@python.org > Subject: Re: [Tutor] FW: wierd replace problem > > > > On 14 September 2010 21:10, Roelof Wobben >> wrote: > I understand it but I try to

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Steven D'Aprano
On Wed, 15 Sep 2010 07:20:33 am Walter Prins wrote: > Correction on my last paragraph on my last mail: > "See also when Python is asked to "print" the string, you can see the > escape characters really there." -> "See also when Python is asked to > "print" the string, you can see the escape charact

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Walter Prins
Correction on my last paragraph on my last mail: "See also when Python is asked to "print" the string, you can see the escape characters really there." -> "See also when Python is asked to "print" the string, you can see the escape characters aren't part of the actual contents of the string." _

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Walter Prins
On 14 September 2010 21:10, Roelof Wobben wrote: > I understand it but I try to understand why in a file there is this 'word > python makes a "'word. > Python doesn't change what it reads from the file. However, depending on how you ask Python to tell you what it's read (or what the contents of

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Roelof Wobben
> Date: Tue, 14 Sep 2010 21:05:06 +0100 > Subject: Re: [Tutor] FW: wierd replace problem > From: wpr...@gmail.com > To: rwob...@hotmail.com > CC: tutor@python.org > > Roelof, > > On 14 September 2010 17:35, Roelof Wobben >> wrot

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Walter Prins
Roelof, On 14 September 2010 17:35, Roelof Wobben wrote: > But how can I use the triple quotes when reading a textf-file ? > To repeat what I said before, obviously not clearly enough: All the quoting stuff, escaping stuff, all of that ONLY APPLIES TO STRINGS/DATA INSIDE OF YOUR PYTHON CODE.

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Francesco Loffredo
On 14/09/2010 18.35, Roelof Wobben wrote: ... It was not confusing when I read your explanation. Still im grazy wht with you and Joel the strip works and with me I get errors. But how can I use the triple quotes when reading a textf-file ? Very easy: YOU DON'T NEED TO USE ANY QUOTES. All the qu

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Roelof Wobben
> From: rwob...@hotmail.com > To: sander.swe...@gmail.com > Subject: RE: [Tutor] FW: wierd replace problem > Date: Tue, 14 Sep 2010 17:40:28 + > > > > > >> From: sander.swe...@

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Sander Sweers
- Original message - > 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. Maybe the link below makes it clear what backslash really does. http://pythonconquerstheuni

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Joel Goldstick
On Tue, Sep 14, 2010 at 12:35 PM, Roelof Wobben wrote: > > > > > But how can I use the triple quotes when reading a textf-file ? > Roelof > The triple quotes let you put quotes inside them... for instance if you want to check for single and double quotes, and ) you can do this: """'")""" its h

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Timo
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

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Roelof Wobben
Date: Tue, 14 Sep 2010 17:45:35 +0200 From: f...@libero.it To: tutor@python.org Subject: Re: [Tutor] FW: wierd replace problem On 14/09/2010 16.29, Roelof Wobben wrote: >... > Oke, > > I see the problem. > > When I have this sentence

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Francesco Loffredo
On 14/09/2010 16.29, Roelof Wobben wrote: ... Oke, I see the problem. When I have this sentence : `'Tis so,' said the Duchess: `and the moral of that is--"Oh, 'tis love, 'tis love, that makes the world go round!"' And I do string.strip() the output will be : `'This and that one does not fit

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Roelof Wobben
> From: rwob...@hotmail.com > To: joel.goldst...@gmail.com > Subject: RE: [Tutor] FW: wierd replace problem > Date: Tue, 14 Sep 2010 15:43:42 + > > > > > >> Date: Tue, 14 Sep 2010 11

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Joel Goldstick
On Tue, Sep 14, 2010 at 10:29 AM, Roelof Wobben wrote: I offer my solution. I didn't bother to make every word lower case, and I think that would improve the result Please offer critique, improvements Some explaination: line 5 -- I read the complete text into full_text, while first replacing

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Roelof Wobben
> From: st...@pearwood.info > To: tutor@python.org > Date: Tue, 14 Sep 2010 21:30:01 +1000 > Subject: Re: [Tutor] FW: wierd replace problem > > On Tue, 14 Sep 2010 05:38:18 pm Roelof Wobben wrote: > >>>> Strip (&#x

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Steven D'Aprano
On Tue, 14 Sep 2010 05:38:18 pm Roelof Wobben wrote: > >> Strip ('"'') does not work. > >> Still this message : SyntaxError: EOL while scanning string > >> literal [...] > I understand what you mean but we're talking about a text-file which > will be read in a string. So I can't escape the quotes.

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Roelof Wobben
Oke, Can this also be the same problem. In the text is this : 'tis is represent as "'this And this part is represent as part. Roelof > Date: Tue, 14 Sep 2010 11:41:28 +0100 > From: wpr...@gmail.com > To: tutor@python.org &

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Francesco Loffredo
On 13/09/2010 20.21, Roelof Wobben wrote: ... The problem as stated in the book is : 3.Write a program called alice_words.py that creates a text file named alice_words.txt containing an alphabetical listing of all the words found in alice_in_wonderland.txt together with the number of times e

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Walter Prins
On 14 September 2010 11:09, James Mills wrote: > $ python > Python 2.6.5 (r265:79063, Jun 13 2010, 14:03:16) > [GCC 4.4.4 (CRUX)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> s = "foo\"bar'" > >>> s > 'foo"bar\'' > I'd like to point something out here.

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread James Mills
On Tue, Sep 14, 2010 at 5:28 PM, Roelof Wobben wrote: > Strip ('"'') does not work. > Still this message : SyntaxError: EOL while scanning string literal > > So I think I go for the suggestion of Bob en develop a programm which deletes > all the ' and " by scanning it character by character. I s

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Walter Prins
On 14 September 2010 08:38, Roelof Wobben wrote: > > I understand what you mean but we're talking about a text-file which will > be read in a string. > So I can't escape the quotes. As far as I know I can't control how Python > is reading a text-file with quotes. > > Putting a value into a strin

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Roelof Wobben
> Date: Tue, 14 Sep 2010 09:32:38 +0200 > From: timomli...@gmail.com > To: tutor@python.org > Subject: Re: [Tutor] FW: wierd replace problem > > On 14-09-10 09:28, Roelof Wobben wrote: >> >> >> Hello, >> &g

Re: [Tutor] FW: wierd replace problem

2010-09-14 Thread Timo
On 14-09-10 09:28, Roelof Wobben wrote: Hello, Strip ('"'') does not work. Still this message : SyntaxError: EOL while scanning string literal Review it again, see how many quotes you are using. For example, this won't work either: >>> s = 'foo'bar' You need to escape the quotes with a

Re: [Tutor] FW: wierd replace problem

2010-09-13 Thread Steven D'Aprano
On Tue, 14 Sep 2010 08:05:33 am bob gailer wrote: > > 3.Write a program called alice_words.py that creates a text file > > named alice_words.txt containing an alphabetical listing of all the > > words found in alice_in_wonderland.txt together with the number of > > times each word occurs. The firs

Re: [Tutor] FW: wierd replace problem

2010-09-13 Thread bob gailer
On 9/13/2010 2:21 PM, Roelof Wobben wrote: From: rwob...@hotmail.com To: bgai...@gmail.com Subject: RE: [Tutor] wierd replace problem Date: Mon, 13 Sep 2010 18:19:43 + I suggest you give a clear, complete and correct problem statement. Right now

Re: [Tutor] FW: wierd replace problem

2010-09-13 Thread Roelof Wobben
> Date: Mon, 13 Sep 2010 15:31:08 -0400 > Subject: Re: [Tutor] FW: wierd replace problem > From: joel.goldst...@gmail.com > To: rwob...@hotmail.com > > > > On Mon, Sep 13, 2010 at 2:24 PM