Skip to content

Instantly share code, notes, and snippets.

@AClon314
Created February 15, 2026 02:00
Show Gist options
  • Select an option

  • Save AClon314/e3c7a4414bef1890e47ad173d533fcad to your computer and use it in GitHub Desktop.

Select an option

Save AClon314/e3c7a4414bef1890e47ad173d533fcad to your computer and use it in GitHub Desktop.
isBasicType/isLeaf
def isBasicType(o):
return isinstance(o, str) or not isinstance(o, (Mapping, Sequence))
def isLeaf(obj):
if isinstance(obj, Mapping):
return all(isBasicType(v) for v in obj.values())
if isinstance(obj, Sequence):
return all(isBasicType(v) for v in obj)
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment