[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can global variable be passed into Python function?

Chris Angelico <rosuav at gmail.com>:

> Python currently has dispatch tables and if/elif chains, and a strong
> cultural aversion to switch. You could change that by coming up with
> some *really* awesome proposal, but you'll be fighting against the
> tide a bit.

It's easy have a "cultural aversion" when the language doesn't provide
the facility.

Switch statements provide for excellent readability in parsers and state
machines, for example. They also allow the Python compiler to optimize
the statement internally unlike long if-else chains.