First things first: while this obviously comes from real code, the way you "anonymized" your code doesn't work, eg. sys.argve
doesn't exist.
I'm trying to make this code easy for someone to read and add more cases.
If you want Python developers to be able to read your code easily, please follow PEP 8 (using a tool such as pep8). That includes sticking to 80 columns, using underscored_names
and using ALL_CAPS
variables for constant strings.
Most of this code in the
if else
statements are very similar. I feel like I might be able to use a lambda to clean this code up but I'm not sure that will work. What is the best way of avoiding a lot of the repetition in this code?
First, withoutWithout having tried to improve yoruyour code yet, using list comprehensions and lambdas is a good way to shorten code, but short code != readable code.
To be continued (hopefully).