I have
foo=("bob","smith","123")
and sometimes
foo=(("bob","smith","123"),("sam","smith","124"))
and a for loop:
for rows in foo:
But I want the for loop to treat foo as a list of rows even if it just one row inside it instead of n many. Right now if I only get passed in the 1st foo, it will iterate by bob, smith, 123 but if I pass the 2nd foo it will iterate by rows (which is what I want). The objects are pyodbc.Row.
Another way of saying this is that I want to be able to use:
foo[0][1]=stuff
If I am passed many rows, or just one.
How can I do this?
A trick I use often inside a function that accepts different types of inputs is to first normalize the uncommon input to the common type, and then handle the common type. Similarly, in your case you could do something like (untested):