{"library":"spectate","title":"Spectate: Track Mutable Data Changes","type":"library","description":"Spectate (v1.0.1) is a Python library designed to track changes to mutable data types, providing undo/redo capabilities for operations on objects like dictionaries and lists. It achieves this by wrapping functions that modify tracked objects, recording events for each change. The library is currently feature-complete and in maintenance mode, with a slow release cadence.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install spectate"],"cli":null},"imports":["from spectate import track","from spectate import undo","from spectate import redo","from spectate import rollback","N/A (removed)"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/rmorshea/spectate","docs":null,"changelog":null,"pypi":"https://pypi.org/project/spectate/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"from spectate import track, undo, redo\n\na = {}\n\n@track(a)\ndef add_entry(key, value):\n    a[key] = value\n\nadd_entry('x', 1)\nadd_entry('y', 2)\nprint(f\"Initial state: {a}\")\n\nundo()\nprint(f\"After first undo: {a}\")\n\nundo()\nprint(f\"After second undo: {a}\")\n\nredo()\nprint(f\"After first redo: {a}\")\n\nredo()\nprint(f\"After second redo: {a}\")","lang":"python","description":"This example demonstrates how to use `spectate.track` to observe changes to a dictionary, and then `undo` and `redo` those changes. The `@track` decorator wraps the `add_entry` function, automatically recording each modification to the dictionary `a`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}