iterating over lines in a file

Jason F. McBrayer jmcbray at carcosa.net
Sat Jul 22 13:15:38 EDT 2000


>>>>> "n" == nobody  <no at bo.dy> writes:

n> cjc26 at nospam.cornell.edu (Cliff Crawford), in

>>> i despise machines trying to second- guess my intentions, and silly
>>> little print statements trying to be clever with their arguments are
>>> nothing more than that.

>> print doesn't really try to be clever with its arguments, except for
>> printing a space between each one and a newline at the end.

n> that's trying to be clever. then, if i'm reading raw lines from a file and
n> want to print them verbatim, i have to strip a newline somewhere somehow?
n> how do i copy a file to another one, is there a file.copy method in some
n> module somewhere?

There is, but that's not important here.  What you really want
is to not use print; use the write method of a file object (such as
sys.stderr or sys.stdout).  That doesn't try to be clever with its
arguments like print does (python's print is not perl's print).

-- 
+-----------------------------------------------------------+
| Jason F. McBrayer                    jmcbray at carcosa.net  |
| A flower falls, even though we love it; and a weed grows, |
| even though we do not love it.            -- Dogen        |



More information about the Python-list mailing list