Re: [Tutor] Adding line numbers to a Python Script

2010-06-12 Thread Alan Gauld
"Sudip Bhattacharya" wrote for line in fileinput.input(inplace = true)(2) line = line.rstrip()(3) num=fileinput.lineno()..(4) print '%-40s #%2i' %(line,num).(5) Line (3) - Are we stri

[Tutor] Adding line numbers to a Python Script

2010-06-12 Thread Sudip Bhattacharya
I quote this example (and the problem that I am facing trying to understand) from the book "Beginning Python - From Novice to Professional" by Magnus Lie Hetland Page 227 # numberlines.py import fileinput(1) for line in fileinput.input(inplace = true)(2) li