I have code that looks like this:
def transform_incoming_json_item(item, things=[]):
if isinstance(item, list):
for thing in item:
things.append(process_thing(thing))
elif isinstance(item, dict):
things.append(process_thing(item))
return things
Is there a more pythonic way of doing this while making only a single call to process_thing (while preserving the type check and the two cases, loop vs. no loop needed)?
(Note: "more pythonic" added in edit to clarify question.)