from collections import Mapping, Sequence
isinstance('ac', Sequence)
isinstance('ac', Mapping)
isinstance({(3): 42}, Mapping)
isinstance({(3): 42}, Sequence)
How to distinguish between a sequence and a mapping