strip() 2.4.4

2007-06-21 Thread Nick
strip() isn't working as i expect, am i doing something wrong - Sample data in file in.txt: 'AF':'AFG':'004':'AFGHANISTAN':'Afghanistan' 'AL':'ALB':'008':'ALBANIA':'Albania' 'DZ':'DZA':'012':'ALGERIA':'Algeria' 'AS':'ASM':'016':'AMERICAN SAMOA':'American Samoa' Code: f1 = open('in.txt', 'r')

Re: strip() 2.4.4

2007-06-21 Thread Stephen R Laniel
On Thu, Jun 21, 2007 at 06:23:01AM -0700, Nick wrote: Why is there a apostrophe still at the end? Is it possible that you actually have whitespace at the end of the line? So then strip() is looking for an apostrophe at the end of the line, not finding it, and therefore not stripping it? --

Re: strip() 2.4.4

2007-06-21 Thread linuxprog
Stephen R Laniel a écrit : On Thu, Jun 21, 2007 at 06:23:01AM -0700, Nick wrote: Why is there a apostrophe still at the end? Is it possible that you actually have whitespace at the end of the line? So then strip() is looking for an apostrophe at the end of the line, not finding it,

Re: strip() 2.4.4

2007-06-21 Thread Roy Smith
In article [EMAIL PROTECTED], Nick [EMAIL PROTECTED] wrote: strip() isn't working as i expect, am i doing something wrong - Sample data in file in.txt: 'AF':'AFG':'004':'AFGHANISTAN':'Afghanistan' 'AL':'ALB':'008':'ALBANIA':'Albania' 'DZ':'DZA':'012':'ALGERIA':'Algeria'

Re: strip() 2.4.4

2007-06-21 Thread Stephen R Laniel
On Thu, Jun 21, 2007 at 01:42:03PM +, linuxprog wrote: that should work for you ? I reproduced the original poster's problem by adding one extra space after the final ' on each line. I'd vote that that's the problem. -- Stephen R. Laniel [EMAIL PROTECTED] Cell: +(617) 308-5571

Re: strip() 2.4.4

2007-06-21 Thread Neil Cerutti
On 2007-06-21, Nick [EMAIL PROTECTED] wrote: strip() isn't working as i expect, am i doing something wrong - Sample data in file in.txt: 'AF':'AFG':'004':'AFGHANISTAN':'Afghanistan' 'AL':'ALB':'008':'ALBANIA':'Albania' 'DZ':'DZA':'012':'ALGERIA':'Algeria' 'AS':'ASM':'016':'AMERICAN

Re: strip() 2.4.4

2007-06-21 Thread Peter Otten
Nick wrote: strip() isn't working as i expect, am i doing something wrong - Sample data in file in.txt: 'AF':'AFG':'004':'AFGHANISTAN':'Afghanistan' 'AL':'ALB':'008':'ALBANIA':'Albania' 'DZ':'DZA':'012':'ALGERIA':'Algeria' 'AS':'ASM':'016':'AMERICAN SAMOA':'American Samoa' Code:

Re: strip() 2.4.4

2007-06-21 Thread Nick
On 21 Jun, 14:53, Neil Cerutti [EMAIL PROTECTED] wrote: On 2007-06-21, Nick [EMAIL PROTECTED] wrote: strip() isn't working as i expect, am i doing something wrong - Sample data in file in.txt: 'AF':'AFG':'004':'AFGHANISTAN':'Afghanistan' 'AL':'ALB':'008':'ALBANIA':'Albania'

Re: strip() 2.4.4

2007-06-21 Thread Richie Hindle
[Nick] Why is there a apostrophe still at the end? [Stephen] Is it possible that you actually have whitespace at the end of the line? It's the newline - reading lines from a file doesn't remove the newlines: from cStringIO import StringIO DATA = \