Skip to content

Instantly share code, notes, and snippets.

@stephengruppetta
Created July 6, 2023 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephengruppetta/149c3b9e93be2d367af701d99c0bb20e to your computer and use it in GitHub Desktop.
Save stephengruppetta/149c3b9e93be2d367af701d99c0bb20e to your computer and use it in GitHub Desktop.
import collections
# A tuple is iterable
print(isinstance((2, 4, 6), collections.abc.Iterable))
# True
# A dictionary is a mapping
print(isinstance({"Jim": 10, "Chris": 12}, collections.abc.Mapping))
# True
# But a dictionary is not a sequence
print(isinstance({"Jim": 10, "Chris": 12}, collections.abc.Sequence))
# False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment