{"id":4658,"library":"objprint","title":"Objprint - Pretty Print Python Objects","description":"objprint is a Python library designed to print Python objects in a human-readable format, simplifying debugging and inspection. It provides a primary function `op()` and a decorator `@add_objprint` for custom classes. The library is actively maintained, with its current version being 0.3.0, and has a fairly regular release cadence addressing new Python versions and adding features.","status":"active","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/gaogaotiantian/objprint","tags":["debugging","pretty-print","developer-tool","utility"],"install":[{"cmd":"pip install objprint","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The primary printing function was renamed from `objprint` to `op` in version 0.1.2.","wrong":"from objprint import objprint","symbol":"op","correct":"from objprint import op"},{"symbol":"add_objprint","correct":"from objprint import add_objprint"},{"note":"Used for global configuration of objprint behavior.","symbol":"config","correct":"from objprint import config"}],"quickstart":{"code":"from objprint import op, add_objprint\n\nclass MyObject:\n    def __init__(self, name, value):\n        self.name = name\n        self.value = value\n        self.items = [1, {'a': 2}, 'hello']\n\n    def get_info(self):\n        return f\"{self.name}: {self.value}\"\n\n@add_objprint\nclass AnotherObject:\n    def __init__(self, id_val):\n        self.id = id_val\n        self.nested_obj = MyObject(\"Nested\", 99)\n\n# Print a standard object\nmy_instance = MyObject(\"Test\", 42)\nop(my_instance)\n\n# Print an object decorated with @add_objprint\nanother_instance = AnotherObject(123)\nop(another_instance)\n\n# Example of global configuration (optional)\n# from objprint import config\n# config(indent=4, color=False)\n# op(my_instance)","lang":"python","description":"This quickstart demonstrates how to use the `op()` function to print instances of both standard Python classes and classes decorated with `@add_objprint`. It shows how `objprint` automatically formats object attributes for readability."},"warnings":[{"fix":"Change all calls from `objprint(obj)` to `op(obj)` and imports from `from objprint import objprint` to `from objprint import op`.","message":"The primary printing function was renamed from `objprint` to `op` in version 0.1.2. Code using `objprint(my_object)` will break.","severity":"breaking","affected_versions":"<0.1.2 to >=0.1.2"},{"fix":"While `objprint` prioritizes preventing crashes, you can configure recursion depth and behavior if needed, though this is generally not recommended for typical use cases. See `objprint.config(skip_recursion=...)`.","message":"Objprint includes recursion handling to prevent infinite loops when printing circularly referenced objects. This means deeply nested or self-referential structures might not be fully expanded by default.","severity":"gotcha","affected_versions":">=0.1.4"},{"fix":"Upgrade to version 0.2.2 or newer, which uses `dir()` to list attributes, providing a more comprehensive view.","message":"Prior to version 0.2.2, objprint used `__dict__` to retrieve attributes, which might not show all attributes for objects that don't primarily store state in `__dict__` (e.g., objects using `__slots__` or C-extensions).","severity":"gotcha","affected_versions":"<0.2.2"},{"fix":"Manage output verbosity by configuring `objprint.config(print_methods=False)` or ensure you only enable it when method inspection is specifically needed.","message":"The `print_methods` feature (introduced in 0.2.0) can significantly increase output verbosity by including callable methods. This is off by default, but if enabled, can make output overwhelming.","severity":"gotcha","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}