Looking for a Python Program/Tool That Will Add Line Numbers to a txt File

Steve Holden steve at holdenweb.com
Fri Feb 15 14:43:01 EST 2008


AnonMail2005 at gmail.com wrote:
>> See Subject. It's a simple txt file, each line is a Python stmt, but I need
>> up to four digits added to each line with a space between the number field
>> and the text. Perhaps someone has already done this or there's a source on
>> the web for it. I'm not yet into files with Python. A sudden need has burst
>> upon me. I'm using Win XP.
> 
> I'm not sure why you need the line numbers inserted into the file.
> Alot of
> editors will display and print line numbers.
> 
Perhaps so, but I had to insert line numbers into the code examples in 
"Python Web Programming", for example, because I annotated the code 
using the line numbers and I wasn't about to allow the publishers the 
chance to screw them up.

> My Visual Studio IDE displays file line numbers (it's an option) and
> prints
> them.  I believe there's a free Express Edition that you can download.
> 
> Also, check out http://www.textpad.com/ .  I think you can download an
> evaluation copy.
> 
None of which would have answered by use case. Besides which, maybe the 
OP was just writing a test piece ...

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list