Can global variable be passed into Python function?

Chris Angelico rosuav at gmail.com
Sat Mar 1 17:11:21 EST 2014


On Sun, Mar 2, 2014 at 8:40 AM, Mark H. Harris <harrismh777 at gmail.com> wrote:
> hi Chris,  I don't think you're wrong.  There are two issues for me (and one of them is not how the switch is implemented).
>
> 1) Is it easier for average users of python as a language to read switch case default,  or if elif else ?
>
> I personally can see and understand a switch block 2x to 3x faster than looking at an elif chain. Because I am primarily a C programmer and I personally use and read switch blocks.

Sure. But before you can ask us to consider how readable it is, we
need to have comparisons. Mock up a switch statement equivalent and
show us how it'd be better. I just looked at your version, and
couldn't see any way that it would be an improvement, because it
required that there be the exact same if/elif chain to figure out what
to switch on. So give us your readable version, in an exact
reimplementation of the if/elif chain, so we can see exactly how it
would go.

ChrisA



More information about the Python-list mailing list