{"id":24581,"library":"sexpdata","title":"sexpdata","description":"A simple S-expression parser for Python, supporting both parsing and serialization of S-expressions. Current version is 1.0.2, released January 2023. Development is active but releases are infrequent.","status":"active","version":"1.0.2","language":"python","source_language":"en","source_url":"https://github.com/jd-boyd/sexpdata","tags":["s-expression","parser","serialization","lisp"],"install":[{"cmd":"pip install sexpdata","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"loads is a top-level function, not a method of the module; direct import is idiomatic.","wrong":"import sexpdata; sexpdata.loads()","symbol":"loads","correct":"from sexpdata import loads"},{"note":"Same as loads.","wrong":"import sexpdata; sexpdata.dumps()","symbol":"dumps","correct":"from sexpdata import dumps"}],"quickstart":{"code":"from sexpdata import loads, dumps\n\nsexp_str = '(foo (bar 1 2) \"string\" nil)'\nparsed = loads(sexp_str)\nprint(parsed)  # Output: [Symbol('foo'), [Symbol('bar'), 1, 2], 'string', Symbol('nil')]\n\n# Serialize back\nsexp_out = dumps(parsed)\nprint(sexp_out)  # Output: (foo (bar 1 2) \"string\" nil)","lang":"python","description":"Basic parsing and serialization of an S-expression string."},"warnings":[{"fix":"Check for Symbol('nil') explicitly: from sexpdata import Symbol; if val == Symbol('nil'): ...","message":"sexpdata does not handle nil consistently; nil is parsed as Symbol('nil'), not Python's None. Comparison with None will fail. Use Symbol('nil') or check with .lower() if needed.","severity":"gotcha","affected_versions":"all"},{"fix":"If expecting a single atom, index into the result: parsed[0].","message":"Parsing returns a list for the top-level S-expression, not a single element. A single atom like '42' will return a list containing the atom: [42]. This is different from some other parsers.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from sexpdata import loads","cause":"Importing incorrectly (e.g., import sexpdata then sexpdata.loads). Actually loads is a top-level function; you must import it directly.","error":"AttributeError: module 'sexpdata' has no attribute 'loads'"},{"fix":"Ensure the input is valid S-expression. Validate with a validator or use a try/except block.","cause":"Input string is not properly formatted S-expression (e.g., missing closing parenthesis, stray characters).","error":"ValueError: malformed S-expression at line 1"},{"fix":"Convert the argument to str: loads(str(my_var))","cause":"Passing a non-string (e.g., integer) to loads().","error":"TypeError: expected string or bytes-like object"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}