Python handles globals badly.
Michael Torrie
torriem at gmail.com
Thu Sep 10 10:21:01 EDT 2015
On 09/10/2015 01:27 AM, Antoon Pardon wrote:
> Op 09-09-15 om 19:55 schreef Steven D'Aprano:
>> In fairness to the C creators, I'm sure that nobody back in the early
>> seventies imagined that malware and security vulnerabilities would be as
>> widespread as they have become. But still, the fundamental decisions made
>> by C are lousy. Assignment is an expression?
>
> What is wrong with that?
Makes for a common error of putting an assignment in a conditional
expression like:
if (a=4) this_is_always_true();
GCC will give you a warning over that these days. But many C
programmers still adopt a notation of
if (4 == a) do_something();
to protect them if they accidentally leave out one =. If assignment was
not an expression, then the compiler would properly error out every time
you used a solitary = in the conditional of an if statement.
Python strikes a good compromise. You can chain = in an assignment
statement, but you can't use them in a conditional expression.
More information about the Python-list
mailing list