Python handles globals badly.

random832 at random832 at
Thu Sep 10 22:07:44 CEST 2015

On Thu, Sep 10, 2015, at 12:48, Chris Angelico wrote:
> Having assignment be a statement (and therefore illegal in a loop
> condition) makes sense. Having it be an expression that yields a
> useful or predictable value makes sense. Having it be an expression,
> but not returning a value, doesn't.

Why not? Having it not return a value (and thus be illegal in places
that expect a value), but be legal in places like C's comma operator or
Lisp's progn that do not use the value, would make logical sense. Your
while loop could be written as something like "while (ch = getchar();
ch): ..."

The main purpose of this would be to prevent you from using it where a
boolean is expected, which wouldn't be necessary if Python hadn't
repeated C's mistake of spelling it "=".

More information about the Python-list mailing list