iterating over lines in a file

nobody no at bo.dy
Mon Jul 24 08:45:43 EDT 2000


David Bolen <db3l at fitlinxx.com>, in <uhf9g4eam.fsf at ctwd0143.fitlinxx.com>:

[many thanksworthy things snipped - thanks!]

> Just to note too - you mention reading "raw lines" - that's sort of
> oxymoronic, since by definition "lines" have format information (end of
> line markers that differ by platform) that have to be processed, and
> thus you aren't really reading anything "raw" :-)

i wasn't really thinking about that, but now that you mention it, you're
right about that. i'm not just new to python, i'm fairly new to programming
in general, and i don't always have the philosophical insights the right
way around yet. they're the hardest, and most important, part to get.

> Oh BTW, if you really just wanted a file copy, then yes, you could also
> use the higher level copy() method in the shutil module.

what i was actually trying to do was a prepend-this-string-to-that-file
routine, and i think i got it. the straight translation from perl got
really, really long due to all the try-except pairs; i like exceptions
better than perl's "do {} or die" idiom as they're clearer and seem more
flexible, but they're sure more verbose, too.




More information about the Python-list mailing list