Re: [Tutor] str.replace error

2019-04-26 Thread Mats Wichmann
On 4/25/19 10:29 PM, Steven D'Aprano wrote: > On Thu, Apr 25, 2019 at 10:46:31AM -0700, Roger Lea Scherer wrote: > >> with open('somefile') as csvDataFile: >> csvReader = csv.reader(csvDataFile) >> for row in range(100): >> a = "Basic P1" >> str.replace(a, "") >> pr

Re: [Tutor] str.replace error

2019-04-26 Thread Alan Gauld via Tutor
On 26/04/2019 05:29, Steven D'Aprano wrote: > (deliberately? accidently?) run into one of the slightly advanced > corners of Python: unbound methods. Ooh, good catch. I completely forgot that the string class' name is str... That's why he didn't get a name error... -- Alan G Author of the Lea

Re: [Tutor] str.replace error

2019-04-25 Thread Steven D'Aprano
On Thu, Apr 25, 2019 at 10:46:31AM -0700, Roger Lea Scherer wrote: > with open('somefile') as csvDataFile: > csvReader = csv.reader(csvDataFile) > for row in range(100): > a = "Basic P1" > str.replace(a, "") > print(next(csvReader)) I'm not quite sure what you exp

Re: [Tutor] str.replace error

2019-04-25 Thread Alan Gauld via Tutor
On 25/04/2019 18:46, Roger Lea Scherer wrote: > Here is my code: > > import csv > > with open('somefile') as csvDataFile: > csvReader = csv.reader(csvDataFile) > for row in range(100): what happens if there are more rows in the file than 100? Or even if there are less!? > a = "