{"id":28542708,"url":"https://github.com/pomponchik/displayhooks","last_synced_at":"2026-02-10T21:01:53.035Z","repository":{"id":254847229,"uuid":"847694300","full_name":"pomponchik/displayhooks","owner":"pomponchik","description":"Extend the capabilities of the standard displayhook in Python","archived":false,"fork":false,"pushed_at":"2025-11-19T12:35:21.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T17:48:45.930Z","etag":null,"topics":["displayhook","printing","python-repl","repl"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pomponchik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-26T11:15:49.000Z","updated_at":"2025-11-19T12:34:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed0cbb65-50e3-497a-9782-7f457217bbd7","html_url":"https://github.com/pomponchik/displayhooks","commit_stats":null,"previous_names":["pomponchik/displayhooks"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/pomponchik/displayhooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomponchik%2Fdisplayhooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomponchik%2Fdisplayhooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomponchik%2Fdisplayhooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomponchik%2Fdisplayhooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pomponchik","download_url":"https://codeload.github.com/pomponchik/displayhooks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomponchik%2Fdisplayhooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29316368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T20:44:44.282Z","status":"ssl_error","status_checked_at":"2026-02-10T20:44:43.393Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["displayhook","printing","python-repl","repl"],"created_at":"2025-06-09T21:07:20.646Z","updated_at":"2026-02-10T21:01:53.026Z","avatar_url":"https://github.com/pomponchik.png","language":"Python","readme":"# displayhooks\n\n[![Downloads](https://static.pepy.tech/badge/displayhooks/month)](https://pepy.tech/project/displayhooks)\n[![Downloads](https://static.pepy.tech/badge/displayhooks)](https://pepy.tech/project/displayhooks)\n[![Coverage Status](https://coveralls.io/repos/github/pomponchik/displayhooks/badge.svg?branch=main)](https://coveralls.io/github/pomponchik/displayhooks?branch=main)\n[![Lines of code](https://sloc.xyz/github/pomponchik/displayhooks/?category=code)](https://github.com/boyter/scc/)\n[![Hits-of-Code](https://hitsofcode.com/github/pomponchik/displayhooks?branch=main)](https://hitsofcode.com/github/pomponchik/displayhooks/view?branch=main)\n[![Test-Package](https://github.com/pomponchik/displayhooks/actions/workflows/tests_and_coverage.yml/badge.svg)](https://github.com/pomponchik/metronomes/actions/workflows/tests_and_coverage.yml)\n[![Python versions](https://img.shields.io/pypi/pyversions/displayhooks.svg)](https://pypi.python.org/pypi/displayhooks)\n[![PyPI version](https://badge.fury.io/py/displayhooks.svg)](https://badge.fury.io/py/displayhooks)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n\nIt's a micro library for manipulating [`sys.displayhook`](https://docs.python.org/3/library/sys.html#sys.displayhook).\n\nWhen you need to change the standard behavior of `displayhook`, with this library you will do it:\n\n- 💎 declaratively\n- 🫥 compactly\n- 🌞 beautifully\n\n\n## Table of contents\n\n- [**Quick start**](#quick-start)\n- [**Change the displayed value**](#change-the-displayed-value)\n- [**Prohibiting the display of certain types of values**](#prohibiting-the-display-of-certain-types-of-values)\n- [**Automatic recovery of the default hook**](#automatic-recovery-of-the-default-hook)\n\n\n## Quick start\n\nInstall it:\n\n```bash\npip install displayhooks\n```\n\nAnd use:\n\n```python\nimport sys\nfrom displayhooks import not_display\n\nnot_display(int)\n\nsys.displayhook('Most of the adventures recorded in this book really occurred; one or two were experiences of my own, the rest those of boys who were schoolmates of mine.')\n#\u003e 'Most of the adventures recorded in this book really occurred; one or two were experiences of my own, the rest those of boys who were schoolmates of mine.'\nsys.displayhook(666)\n# [nothing!]\n```\n\n## Change the displayed value\n\nYou can declaratively declare a converter function for the printed values. What it returns will be used to call the original `displayhook` function.\n\n```python\nimport sys\nfrom displayhooks import converted_displayhook\n\n@converted_displayhook\ndef new_displayhook(value):\n    return value.lower()\n\nsys.displayhook(\"What’s gone with that boy, I wonder? You TOM!\")\n#\u003e 'what’s gone with that boy, i wonder? you tom!'\n```\n\nIf your function returns `None`, nothing will be printed.\n\n\n## Prohibiting the display of certain types of values\n\nYou can disable the display of certain data types, similar to how [`NoneType`](https://docs.python.org/3/library/types.html#types.NoneType) values are ignored by default.\n\nYou could already see a similar example above, let's look at it again:\n\n```python\nimport sys\nfrom types import FunctionType\nfrom displayhooks import not_display\n\nnot_display(FunctionType)\n\nsys.displayhook('Nothing! Look at your hands. And look at your mouth. What is that truck?')\n#\u003e 'Nothing! Look at your hands. And look at your mouth. What is that truck?'\nsys.displayhook(lambda x: x)\n# [nothing!]\n```\n\nIn this example, you can see that we have disabled the display for functions, but all other data types are displayed unchanged.\n\n\n## Automatic recovery of the default hook\n\nYou can limit the impact on [`sys.displayhook`](https://docs.python.org/3/library/sys.html#sys.displayhook) only to the code inside a function. If you hang the `autorestore_displayhook` decorator on it, after exiting the function, the displayhook that was installed before it was called will be automatically restored:\n\n```python\nimport sys\nfrom types import FunctionType\nfrom displayhooks import not_display, autorestore_displayhook\n\n@autorestore_displayhook\ndef do_something_dangerous():\n    not_display(FunctionType)\n    sys.displayhook(do_something_dangerous)\n    # [nothing!]\n\ndo_something_dangerous()\n\nsys.displayhook(do_something_dangerous)\n#\u003e \u003cfunction do_something_dangerous at 0x104c980e0\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpomponchik%2Fdisplayhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpomponchik%2Fdisplayhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpomponchik%2Fdisplayhooks/lists"}