[SciPy-user] stupid python question : for in in range(nlines) :

Alan G Isaac aisaac at american.edu
Thu Apr 20 12:50:39 EDT 2006


On Thu, 20 Apr 2006, Eric Emsellem apparently wrote: 
> ############################## for i in range(nlines) 
> : ...  ...  while i < nlines : ....  i += 1 if ... : break 
> ############################# 


The for loop provides a rule for assignment to the name 'i',
so that must fail.

Files are iterators:
http://docs.python.org/lib/bltin-file-objects.html
Use 'for line in file:' along with the next() method.

hth,
Alan Isaac







More information about the SciPy-User mailing list