Perhaps as a remnant of my days with a strongly-typed language (Java), I often find myself writing functions and then forcing type checks. For example:
def o
This is a non-idiomatic way of doing things. Typically in Python you would use try/except tests.
try/except
def orSearch(d, query): try: d.get(something) except TypeError: print("oops") try: foo = query[:2] except TypeError: print("durn")