{"id":16444899,"url":"https://github.com/jaymon/pout","last_synced_at":"2025-05-06T20:42:28.321Z","repository":{"id":57454351,"uuid":"4802292","full_name":"Jaymon/pout","owner":"Jaymon","description":"Python pretty print on steroids","archived":false,"fork":false,"pushed_at":"2025-01-21T02:04:21.000Z","size":507,"stargazers_count":30,"open_issues_count":21,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T16:35:02.663Z","etag":null,"topics":["debug","debugging","devtools","printing","python"],"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/Jaymon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2012-06-27T00:26:50.000Z","updated_at":"2025-01-21T02:04:24.000Z","dependencies_parsed_at":"2024-01-09T07:42:47.290Z","dependency_job_id":"6cccc0bc-b624-46a6-88da-3f180ff2e51d","html_url":"https://github.com/Jaymon/pout","commit_stats":{"total_commits":209,"total_committers":1,"mean_commits":209.0,"dds":0.0,"last_synced_commit":"2ce258a59e30428f3d30a9c75c6b5a4b49fde5fa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaymon%2Fpout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaymon%2Fpout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaymon%2Fpout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaymon%2Fpout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jaymon","download_url":"https://codeload.github.com/Jaymon/pout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252768570,"owners_count":21801371,"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":["debug","debugging","devtools","printing","python"],"created_at":"2024-10-11T09:42:32.250Z","updated_at":"2025-05-06T20:42:28.244Z","avatar_url":"https://github.com/Jaymon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pout\n\nA collection of handy functions for printing out variables and debugging Python code.\n\n[print](https://docs.python.org/3/library/functions.html#print) didn't give enough information while debugging, [pprint](https://docs.python.org/3/library/pprint.html) wasn't much better. I was also getting sick of typing things like: `print(\"var = \", var)`.\n\nPout tries to print out variables with their name, and for good measure, it also prints where the `pout` function was called so you can easily find it and delete it when you're done debugging.\n\nI use pout extensively in basically every python project I work on.\n\n\n## Methods\n\n### pout.v(arg1, [arg2, ...]) -- easy way to print variables\n\nexample\n\n```python\nfoo = 1\npout.v(foo)\n\nbar = [1, 2, [3, 4], 5]\npout.v(bar)\n```\n\nshould print something like:\n\n    foo = 1\n    (/file.py:line)\n\n    bar (4) =\n    [\n            0: 1,\n            1: 2,\n            2:\n                    [\n                            0: 3,\n                            1: 4\n                    ],\n            3: 5\n    ]\n    (/file.py:line)\n\nYou can send as many variables as you want into the call\n\n\n```python\n# pass in as many variables as you want\npout.v(foo, bar, che)\n\n# a multi-line call is also fine\npout.v(\n    foo,\n    bar\n)\n```\n\n\n### pout.h() -- easy way to print \"here\" in the code\n\nexample\n\n```python\npout.h(1)\n# do something else\npout.h(2)\n\n# do even more of something else\npout.h()\n```\n\nShould print something like:\n\n    here 1 (/file.py:line)\n\n    here 2 (/file.py:line)\n\n    here N (/file.py:N)\n\n\n### pout.t() -- print a backtrace\n\nPrints a nicely formatted backtrace, by default this should compact system python calls (eg, anything in dist-packages) which makes the backtrace easier for me to follow.\n\nexample:\n\n```python\npout.t()\n```\n\nshould print something like:\n\n    15 - C:\\Python27\\lib\\runpy.py:162\n    14 - C:\\Python27\\lib\\runpy.py:72\n    13 - C:\\Python27\\lib\\unittest\\__main__.py:12\n    12 - C:\\Python27\\lib\\unittest\\main.py:95\n    11 - C:\\Python27\\lib\\unittest\\main.py:229\n    10 - C:\\Python27\\lib\\unittest\\runner.py:151\n    09 - C:\\Python27\\lib\\unittest\\suite.py:65\n    08 - C:\\Python27\\lib\\unittest\\suite.py:103\n    07 - C:\\Python27\\lib\\unittest\\suite.py:65\n    06 - C:\\Python27\\lib\\unittest\\suite.py:103\n    05 - C:\\Python27\\lib\\unittest\\suite.py:65\n    04 - C:\\Python27\\lib\\unittest\\suite.py:103\n    03 - C:\\Python27\\lib\\unittest\\case.py:376\n    02 - C:\\Python27\\lib\\unittest\\case.py:318\n    01 - C:\\Projects\\Pout\\_pout\\src\\test_pout.py:50\n\n            pout.t()\n\n\n### pout.p([title]) -- quick and dirty profiling\n\nexample\n\n```python\np(\"starting profile\")\ntime.sleep(1)\np() # stop the \"starting profile\" session\n\n\n# you can go N levels deep\np(\"one\")\np(\"two\")\ntime.sleep(0.5)\np() # stop profiling of \"two\"\ntime.sleep(0.5)\np() # stop profiling of \"one\"\n\n\n# you can also use with\nwith p(\"benchmarking\"):\n    time.sleep(0.5)\n```\n\nshould print something like:\n\n    starting profile - 1008.2 ms\n      start: 1368137723.7 (/file/path:n)\n      stop: 1368137724.71(/file/path:n)\n\n\n    one \u003e two - 509.2 ms\n      start: 1368137722.69 (/file/path:n)\n      stop: 1368137723.2(/file/path:n)\n\n\n    one - 1025.9 ms\n      start: 1368137722.68 (/file/path:n)\n      stop: 1368137723.7(/file/path:n)\n\n\n### pout.x(arg1, [arg2, ...]) -- like pout.v but then will run sys.exit(1)\n\nThis just prints out where it was called from, so you can remember where you exited the code while debugging\n\nexample:\n  \n```python\npout.x()\n```\n\nwill print something like this before exiting with an exit code of 1:\n\n```python\nexit (/file/path:n)\n```\n\n\n### pout.b([title[, rows[, sep]]]) -- prints lots of lines to break up output\n\nThis is is handy if you are printing lots of stuff in a loop and you want to break up the output into sections.\n\nexample:\n\n```python\npout.b()\npout.b('this is the title')\npout.b('this is the title 2', 5)\npout.b('this is the title 3', 3, '=')\n```\n\nWould result in output like:\n\n    ********************************************************************************\n    (/file/path:n)\n\n\n    ****************************** this is the title *******************************\n    (/file/path:n)\n\n\n    ********************************************************************************\n    ********************************************************************************\n    ***************************** this is the title 2 ******************************\n    ********************************************************************************\n    ********************************************************************************\n    (/file/path:n)\n\n\n    ================================================================================\n    ============================= this is the title 3 ==============================\n    ===============================================================================\n    (/file/path:n)\n\n\n### pout.c(str1, [str2, ...]) -- print info about each char in each str\n\nKind of like `od -c` on the command line.\n\nexample:\n\n```python\npout.c('this')\n```\n\nwill print something like:\n\n    Total Characters: 4\n    t\t't'\t\\u0074\tLATIN SMALL LETTER T\n    h\t'h'\t\\u0068\tLATIN SMALL LETTER H\n    i\t'i'\t\\u0069\tLATIN SMALL LETTER I\n    s\t's'\t\\u0073\tLATIN SMALL LETTER S\n    (/file/path:n)\n\nThis could fail if Python isn't compiled with 4 byte unicode support, just something to be aware of, but chances are, if you don't have 4 byte unicode supported Python, you're not doing much with 4 byte unicode.\n\n\n### pout.s(arg1, [arg2, ...]) -- easy way to return pretty versions of variables\n\n  Just like `pout.v()` but will return the value as a string\n\n\n### pout.ss(arg1, [arg2, ...]) -- easy way to return pretty versions of variables without meta information\n\n  Just like `pout.vv()` but will return the value as a string\n\n\n### pout.l([logger_name, [logger_level]]) -- turn logging on just for this context\n\nTurns logging on for the given level (defaults to `logging.DEBUG`) and prints the logs to __stderr__. Useful when you just want to check the logs of something without modifying your current logging configuration.\n\nexample:\n\n```python\nwith pout.l():\n    logger.debug(\"This will print to the screen even if logging is off\")\nlogger.debug(\"this will not print if logging is off\")\n\nwith pout.l(\"name\"):\n    # if \"name\" logger is used it will print to stderr\n# \"name\" logger goes back to previous configuration\n```\n\n### pout.tofile([path])\n\nRoutes pout's output to a file (defaults to `./pout.txt`)\n\nexample:\n\n```python\nwith pout.tofile():\n\t# everything in this with block will print to a file in current directory\n\tpout.b()\n\ts = \"foo\"\n\tpout.v(s)\n\t\npout.s() # this will print to stderr\n```\n\n\n## Customizing Pout\n\n### object magic method\n\nAny class object can define a `__pout__` magic method, similar to Python's built in `__str__` magic method that can return a customized string of the object if you want to. This method can return anything, it will be run through Pout's internal stringify methods to convert it to a string and print it out.\n\n\n## Console commands\n\n### pout json\n\nrunning a command on the command line that outputs a whole a bunch of json? Pout can help:\n\n    $ some-command-that-outputs-json | pout json\n\n\n### pout char\n\nRuns `pout.c` but on the output from a command line script:\n\n    $ echo \"some string with chars to analyze\" | pout char\n\n\n## Install\n\nUse PIP\n\n    pip install pout\n\nGenerally, the pypi version and the github version shouldn't be that out of sync, but just in case, you can install from github also:\n\n    pip install -U \"git+https://github.com/Jaymon/pout#egg=pout\"\n\n\n-------------------------------------------------------------------------------\n\n## Make Pout easier to use\n\nWhen debugging, it's really nice not having to put `import pout` at the top of every module you want to use it in, so there's a command for that, if you put:\n\n```python\nimport pout\npout.inject()\n```\n\nSomewhere near the top of your application startup script, then `pout` will be available in all your files whether you imported it or not, it will be just like `str`, `object`, or the rest of python's standard library.\n\nIf you don't even want to bother with doing that, then just run:\n\n```\n$ pout inject\n```\n\nfrom the command line and it will modify your python environment to make pout available as a builtin module, just like the python standard library. This is super handy for development virtual environments.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaymon%2Fpout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaymon%2Fpout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaymon%2Fpout/lists"}