I still prefer the if hasattr(data, "get"): , because we don't know what is inside the data. It adds a layer of type abstraction.