Still OT ...
But I do think you need to consider not just your editor
-- if anyone else is going to read your code.
They're not (in any universe I can imagine).
Exactly -- the most important thing about style is that it be consistent within a project's development team -- if that's just you, then you're all set.
you also have other checks
in there, so those would have to be moved into the
functions in the dict, maybe with wrappers (or not --
depends on where you store some of that state data.
Exactly. Some wasted effort to turn
a simple, contiguous, transparent chunk of code into
something more complicated, spread out and harder to understand.
As i said -- depends on the rest of your code. It could make it less spread out and easier to understand :-)
For the most part using a dict to switch makes the most sense if the same pattern will be used with multiple "switch dicts".
Again, turning simple straightforward into
more complicated code. (I'm quite capable of writing tricks like
that *when I think they're appropriate*; I've done it many times.)
I'm not sure I'd call it "tricks" -- but anyway, I've found that big nested ifelses are rarely the cleanest solution -- but not never.
- Chris B.
Christopher Barker, PhD (Chris)
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython