Suppose I have this:
def incrementElements(x): return x+1
but I want to modify it so that it can take either a numpy array, an iterable, or
Existing solutions all work. Here's yet another option.
def incrementElements(x): try: iter(x) except TypeError: x = [x] x = np.array(x) # code that operators on x