So, I'm trying to be a good Python programmer and duck-type wherever I can, but I've got a bit of a problem where my input is either a dict
or a list
of dict
s.
I can't distinguish between them being iterable, because they both are.
My next thought was simply to call list(x)
and hope that returned my list intact and gave me my dict as the only item in a list; alas, it just gives me the list of the dict's keys.
I'm now officially out of ideas (short of calling isinstance
which is, as we all know, not very pythonic). I just want to end up with a list of dicts, even if my input is a single solitary dict.