def as_json(w): ''' Return the current state of the World object w as a JSON string. Functions are converted to JS objects containing the functions' names. ''' stack, dictionary = w.getCurrentState() dictionary = list(name for name, function in items(dictionary)) return json.dumps((stack, dictionary), default=_p, indent=2)
def as_json(w=W): stack, dictionary = w.getCurrentState() dictionary = list(name for name, function in items(dictionary)) return json.dumps((stack, dictionary), default=p, indent=2)