Can global variable be passed into Python function?

Mark H. Harris harrismh777 at gmail.com
Fri Feb 28 19:04:12 CET 2014


On Friday, February 28, 2014 9:50:09 AM UTC-6, Steven D'Aprano wrote:

> > PS On the topic of enums, when are we getting support for a switch
> > statement?

> http://legacy.python.org/dev/peps/pep-3103/
> http://legacy.python.org/dev/peps/pep-0275/
> 

I have reviewed these peps, and I heard Guido's 2007 keynote, as well I have heard him speak on YouTube several times about the inadvisability of a pythonized  switch statement (similar to C). 

I think the real issue is about the syntax... because of python's unique indent strategy going back to ABC, a pythonized switch statement would play havoc with the many text parsers out there used for development (TestWrangler, and many others). 

Personally I would still like to see a pythonized switch statement at some point.  I prefer the syntactical form of PEP 275,   but unlike the notion of dropping optimization and converting to if elif else under the proverbial covers,  I would prefer to see a conversion to the dict dispatch table under the covers. 

At any rate...  and I don't think even Guido can really argue against this,...   a switch statement is just more readable to human beings that a dict dispatch table, or a long if elif chain... and one of the main points of python (going all the way back to ABC) was to make very highly readable code.

marcus



More information about the Python-list mailing list