Python handles globals badly.

Steven D'Aprano steve at pearwood.info
Tue Sep 8 23:27:02 EDT 2015


On Tue, 8 Sep 2015 06:59 pm, Antoon Pardon wrote:

> Op 04-09-15 om 02:47 schreef Mark Lawrence:
>> On 04/09/2015 01:06, Michael Torrie wrote:
>>> On 09/03/2015 01:05 PM, tdev at freenet.de wrote:
>>>
>>>> [The same e.g. with switch statement: add it]
>>>
>>> Switch is a nice-to-have thing, but definitely not essential. A PEP here
>>> (probably already has been several) would at least be read anyway.
>>> However, there are several idiomatic ways of accomplishing the same
>>> thing that are often good enough and familiar to any Python programmer
>>> out there.  Since functions are first-class objects, often a dispatch
>>> table is the best way to go here.
>>>
>>
>> https://www.python.org/dev/peps/pep-3103/ "A Switch/Case Statement" by
>> Guido van Rossum, "Rejection Notice - A quick poll during my keynote
>> presentation at PyCon 2007 shows this proposal has no popular support.
>> I therefore reject it".
>>
>> https://www.python.org/dev/peps/pep-0275/ "Switching on Multiple
>> Values" by Marc-André Lemburg, "Rejection Notice - A similar PEP for
>> Python 3000, PEP 3103 [2], was already rejected, so this proposal has
>> no chance of being accepted either."
>>
> Were those polls, like the poll he once did for the condtional expression?
> There the poll indicated no specific proposal had a majority, so for each
> specific proposal one could say it didn't have popular support, but the
> majority still prefered to have a conditional expression. But at that
> time Guido used that poll as an indication there was not enough support.

In the case of conditional expression, there is *no good alternative*.

Using if...then statement is too heavyweight, and cannot be used in an
expression. Using "flag and true_value or false_value" is buggy -- it fails
if true_value is itself false. Refactoring it to a function uses eager
rather than lazy evaluation. So there was no existing alternative to a
ternary if expression that worked correctly.

In the case of case/switch, there is no consensus on what the statement
should do, how it should work, what purpose it has, or what syntax it
should use. Rather than "there's no alternative to a case statement", the
situation was more like "there are many good alternatives to the various
different case statements people want".



-- 
Steven




More information about the Python-list mailing list