Re: [Tutor] Read file line by line

2005-01-26 Thread Alan Gauld
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

Re: [Tutor] Read file line by line

2005-01-25 Thread Danny Yoo
On Tue, 25 Jan 2005, Gilbert Tsang wrote: Hey you Python coders out there: Being a Python newbie, I have this question while trying to write a script to process lines from a text file line-by-line: #!/usr/bin/python fd = open( test.txt ) content = fd.readline() while (content != ):

Re: [Tutor] Read file line by line

2005-01-25 Thread Danny Yoo
There's nothing that really technically prevents us from doing an assignment as an expression, but Python's language designer decided that it encouraged a style of programming that made code harder to maintain. By making it a statement, it removes the possiblity of making a mistake like: