Python Success Stories or Nightmares

Alexander Schmolck a.schmolck at
Tue Feb 4 01:11:08 CET 2003

Grzegorz Adam Hankiewicz <gradha at> writes:

> On Mon, Feb 03, 2003 at 01:58:16AM +0000, Alexander Schmolck wrote:
> > Well, given that there simply *is* no reason to "miss that
> > one-liner" you mention above -- as it would just provide an idiotic
> > way to write:
> > 
> >  for line in file:...           # doesn't need more RAM BTW
> Especially in Python 1.5...

Iterating over files is just as likely to be retrofitted to python 1.5 as
assignments in expressions, so what's your point?

For the record: I can understand why you and other people want python to be
modified to allow assignments in expressions (although I'm against it), but
the example you gave didn't make *any* case for the utility of such a
change. So I think your apparent irritation with posters who attributed your
poor example to your ignorance of the ``for line in file`` idiom is a bit
unjustified, especially since your formulation of "missing that one-liner"
suggested that you missed that particular application of assignment in
expressions rather than the facility itself.

Maybe you can come up with a good example, why you'd like assignment in
expressions, but as far as the pattern:

  while (x = ...) != ...:

is concerned, unless either of the '...'s contain values that are modified
somehow within the loop, why not just do:

  for x in ...


Seems much clearer and doesn't require any modification of python's syntax.


More information about the Python-list mailing list