[Tutor] Read file line by line

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Jan 26 03:01:27 CET 2005



> 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:
>
> ###
> if ((ch = getch()) = 'q') { ... }
> ###

....hmmm.  This doesn't compile.  Never mind, I screwed up.  *grin*


But the Python FAQ does have an entry about this topic, if you're
interested:

http://python.org/doc/faq/general.html#why-can-t-i-use-an-assignment-in-an-expression



More information about the Tutor mailing list