Python — Nested Ifs Nov 2019

NESTED IFs: A question was asked recently on Stack Overflow The solution shown below is readable, scalable, easily edited — and contains no IF statements. This is similar to the method proposed by Anitoliy R except I use a single string and the split function to simplify editing and scaling. To illustrate scalability, I add […]

get_next, get_prev, in Python OrderedDict Aug 2018

I provide an example class based on an OrderedDict — with an adjunct dictionary to index to the next and prev OrderedDict entry. In my case, I have a rather static OrderedDict: it is a dictionary of AISC shape objects. The function set_prev_next() must be called after each operation that modifies OrderedDict. class MyClass(coll.OrderedDict): mynpdict […]