Skip to content

Instantly share code, notes, and snippets.

@Ksengine
Last active December 19, 2020 13:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ksengine/3c3b08ca3654ef20bbc11c2ef3c16936 to your computer and use it in GitHub Desktop.
Save Ksengine/3c3b08ca3654ef20bbc11c2ef3c16936 to your computer and use it in GitHub Desktop.
""" 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