> 1. Why does the assignment-and-test in one line not allowed in
Python?
> For example, while ((content = fd.readline()) != ""):

Because Guido didn't write it that way? ;-)

And that may have been because it is such a common source of bugs.
So common in fact that many compilers now offer to emit a warning
when they detect it...just in case you meant to use ==...

> 2. I know Perl is different, but there's just no equivalent of while
> ($line = <A_FILE>) { } ?

Take a look at the fileinput module
and of course

for line in fd:
   #do something

works too.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to