{"id":21082195,"url":"https://github.com/olsonpm/py_pretty-simple-namespace","last_synced_at":"2025-08-01T15:41:50.484Z","repository":{"id":57454725,"uuid":"166881608","full_name":"olsonpm/py_pretty-simple-namespace","owner":"olsonpm","description":null,"archived":false,"fork":false,"pushed_at":"2019-05-19T20:45:52.000Z","size":183,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2025-01-20T23:45:26.175Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olsonpm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-21T21:13:52.000Z","updated_at":"2019-05-19T20:45:54.000Z","dependencies_parsed_at":"2022-09-05T05:41:20.045Z","dependency_job_id":null,"html_url":"https://github.com/olsonpm/py_pretty-simple-namespace","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fpy_pretty-simple-namespace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fpy_pretty-simple-namespace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fpy_pretty-simple-namespace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olsonpm%2Fpy_pretty-simple-namespace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olsonpm","download_url":"https://codeload.github.com/olsonpm/py_pretty-simple-namespace/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243526853,"owners_count":20305112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-19T20:13:06.343Z","updated_at":"2025-03-14T04:43:08.844Z","avatar_url":"https://github.com/olsonpm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pretty SimpleNamespace\n\n\u003c!-- pypiwarn --\u003e\n\n\u003cbr\u003e\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**\n\n- [What is it?](#what-is-it)\n- [Why create it?](#why-create-it)\n- [Simple usage](#simple-usage)\n- [Features](#features)\n- [Limitations](#limitations)\n- [Related projects](#related-projects)\n- [Api](#api)\n- [Test](#test)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n\u003cbr\u003e\n\n### What is it?\n\n- A stringifier and formatter for SimpleNamespace which attempts to make the\n  data as readable as possible.\n\n\u003cbr\u003e\n\n### Why create it?\n\n- I use SimpleNamespace often to hold state and needed a way to print it out for\n  debugging purposes.\n\n\u003cbr\u003e\n\n### Simple usage\n\n```py\nfrom pretty_simple_namespace import pprint\nfrom types import SimpleNamespace as o\n\njoe = o(\n    name={\"first\": \"joe\", \"last\": \"schmo\"},\n    age=30,\n    favoriteFoods=[\"apples\", \"steak\"],\n)\n\npprint(joe)\n# prints\n# {\n#   name: {\n#     first: 'joe'\n#     last: 'schmo'\n#   }\n#   age: 30\n#   favoriteFoods: [\n#     'apples'\n#     'steak'\n#   ]\n# }\n```\n\n\u003cbr\u003e\n\n### Features\n- handles recursive structures by tracking and printing references nicely\n- recurses into types `list`, `dict` and `SimpleNamespace` for now\n- has special-case printing for types `bool`, `str`, `callable` and `None`\n  - booleans and None are printed lowercase\n  - strings are wrapped in single quotes\n  - callable appends `()` e.g. `myMethod()`.  Arguments aren't represented\n- all other types are printed by wrapping it in `str` e.g. `str(userDefinedType)`\n\n\u003cbr\u003e\n\n### Limitations\n- multi-line strings look ugly\n- doesn't have a way to recurse into structures other than what's listed above\n\n\u003cbr\u003e\n\n### Related projects\n\n- [tedent](https://github.com/olsonpm/py_tedent)\n\n\u003cbr\u003e\n\n### Api\n\n#### format(something, indent=2) =\u003e str\n- formats `something` to a string as seen in [Simple usage](#simple-usage)\n\n#### pprint(something, indent=2) =\u003e None\n- just prints the formated `something`\n\n#### wrapWith(\\*, indent) =\u003e [Wrapped module](#wrapped-module)\n- use this when you want to call `format` or `pprint` with a different default\n  indent value so you don't have to pass it manually all the time.\n\n  e.g.\n  ```py\n  from pretty_simple_namespace import wrapWith\n\n  pprint = wrapWith(indent=4).pprint\n  pprint(o(tabbed4spaces=True))\n  # {\n  #     tabbed4spaces: true\n  # }\n  ```\n\n#### Wrapped module\n- just an instance of SimpleNamespace with two attributes `format` and `pprint`.\n\n\u003cbr\u003e\n\n### Test\n\n```sh\n#\n# you must have poetry installed\n#\n$ poetry shell\n$ poetry install\n$ python runTests.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folsonpm%2Fpy_pretty-simple-namespace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folsonpm%2Fpy_pretty-simple-namespace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folsonpm%2Fpy_pretty-simple-namespace/lists"}