Last active
December 19, 2020 13:58
-
-
Save Ksengine/3c3b08ca3654ef20bbc11c2ef3c16936 to your computer and use it in GitHub Desktop.
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
""" Python Script Object Notation (PSON) """ | |
# JSON alternative for Python. | |
def stringify(obj): | |
return str(obj) | |
def parse(string): | |
if string[0] == ' ': | |
raise Exception('cannot parse') | |
for i in __builtins__.__dict__: | |
if string.startswith(i+'('): | |
raise Exception('cannot parse') | |
if string.startswith(i+' '): | |
raise Exception('cannot parse') | |
return eval(string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment