More efficient/elegant branching
Python
python at invalid
Tue Dec 10 05:33:56 EST 2019
Musbur wrote:
> Hello,
>
> I have a function with a long if/elif chain that sets a couple of
> variables according to a bunch of test expressions, similar to function
> branch1() below. I never liked that approach much because it is clumsy
> and repetetive, and pylint thinks so as well. I've come up with two
> alternatives which I believe are less efficient due to the reasons given
> in the respective docstrings. Does anybody have a better idea?
I tried a lot of times to write down a useful Switch module
without convincing myself. Recently here is what I ended up
with, what do you think ?
https://gitlab.com/snippets/1921123
More information about the Python-list
mailing list