Created
February 15, 2026 02:00
-
-
Save AClon314/e3c7a4414bef1890e47ad173d533fcad to your computer and use it in GitHub Desktop.
isBasicType/isLeaf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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