# peepshow
![PyPI - Version](https://img.shields.io/pypi/v/peepshow)
![PyPI - License](https://img.shields.io/pypi/l/peepshow)
![PyPI - Downloads](https://img.shields.io/pypi/dm/peepshow)
Provides following utilities for debugging Python applications:
* show - lightweight function that prints name and value of your variable(s) to the console.
* peep - featured, interactive interface for data inspection.
![](https://raw.githubusercontent.com/gergelyk/peepshow/master/docs/demo.gif)
## Resources
* Documentation: <https://gergelyk.github.io/peepshow>
* Repository: <https://github.com/gergelyk/peepshow>
* Package: <https://pypi.python.org/pypi/peepshow>
* Author: [Grzegorz Krasoń](mailto:grzegorz.krason@gmail.com)
* License: [MIT](LICENSE)
## Installation
Install `peepshow` package:
```sh
pip install peepshow
```
PeepShow uses `clear`, `vim`, `man` commands which are available in most of Linux distributions. Users of other operating systems need to install them on their own.
### Built-Ins
If you expect to use peepshow often, consider adding `peep` and `show` commands to Python's built-ins and enabling except hook. Edit either `{site-packages}/sitecustomize.py` or `{user-site-packages}/usercustomize.py` and append the following:
```python
import peepshow
import builtins
builtins.peep = peepshow.peep
builtins.show = peepshow.show
builtins.peep_ = peepshow.peep_
builtins.show_ = peepshow.show_
peepshow.enable_except_hook(consider_env=True)
```
### Breakpoint
It is also possible to invoke `peep()` as a result of calling built-in function `breakpoint()`. To enable such behavior use `PYTHONBREAKPOINT` system variable:
```sh
export PYTHONBREAKPOINT=peepshow.peep
```
## Compatibility
* This software is expected to work with Python 3.6, 3.7, 3.8 and compatible.
* It has never been tested under operating systems other than Linux.
* It works fine when started in a plain Python script, in ipython or ptipython.
* In these environments like interactive python console, in pdb and ipdb, peep and show cannot infer names of the variables in the user context, so they need to be provided explicitly (e.g. use `peep_` and `show_`).
## Usage
### `show`
Running this script:
```python
x = 123
y = {'name': 'John', 'age': 123}
z = "Hello World!"
# show all the variables in the scope
show()
# or only variables of your choice
show(x, y)
# you can also rename them
show(my_var=x)
# use 'show_' to specify variable names as a string
show_('x')
# expressions and renaming are also allowed
show_('x + 321', zet='z')
```
will result in following output:
```
x = 123
y = {'age': 123, 'name': 'John'}
z = 'Hello World!'
x = 123
y = {'age': 123, 'name': 'John'}
my_var = 123
x = 123
x + 321 = 444
zet = 'Hello World!'
```
### `peep`
Try running the following script:
```python
x = 123
y = {'name': 'John', 'age': 123}
z = "Hello World!"
# inspect dictionary that consists of all the variables in the scope
peep()
# or inspect variable of your choice directly
peep(x)
# use 'peep_' to specify variable name as a string
peep_('x')
```
When interactive interface pops up:
* Hit ENTER to see list of available variables.
* Type `10` and hit ENTER to select `y`.
* Hit ENTER again to see items of your dictionary.
* Type `dir` and hit ENTER to list attributes of `y` (excluding built-ins).
* Type `continue` and hit ENTER to proceed or type `quit` and hit ENTER to terminate your script.
Note that all the commands have their short aliases. E.g. `quit` and `q` is the same.
For more help:
* Type `help` and hit ENTER to see list of available commands.
* Type `man` and hit ENTER to read the manual, hit `q` when you are done.
### excepthook
Before running your script, set environment variable `PYTHON_PEEP_EXCEPTIONS` to `1`. Now run the script and see what happens when an exception is raised.
## Development
```sh
# Preparing environment
pip install --user poetry # unless already installed
poetry install
# Testing with coverage
poetry run pytest --cov peepshow --cov tests
# Rendering documentation
poetry run mkdocs serve
# Building package
poetry build
# Releasing
poetry version minor # increment selected component
git commit -am "bump version"
git push
git tag ${$(poetry version)[2]}
git push --tags
poetry build
poetry publish
poetry run mkdocs build
poetry run mkdocs gh-deploy -b gh-pages
```
## Donations
If you find this software useful and you would like to repay author's efforts you are welcome to use following button:
[![Donate](https://www.paypalobjects.com/en_US/PL/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D9KUJD9LTKJY8&source=url)
Raw data
{
"_id": null,
"home_page": "https://gergelyk.github.io/peepshow",
"name": "peepshow",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.6",
"maintainer_email": null,
"keywords": "debug, data, explore, programming",
"author": "Grzegorz Kraso\u0144",
"author_email": "grzegorz.krason@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/61/95/ecbf4be9dfbd0ab36128d6dcc10b3e3a82bce6effbfdebd3fcb729a00eaf/peepshow-0.3.0.tar.gz",
"platform": null,
"description": "# peepshow\n![PyPI - Version](https://img.shields.io/pypi/v/peepshow)\n![PyPI - License](https://img.shields.io/pypi/l/peepshow)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/peepshow)\n\nProvides following utilities for debugging Python applications:\n\n* show - lightweight function that prints name and value of your variable(s) to the console.\n* peep - featured, interactive interface for data inspection.\n\n![](https://raw.githubusercontent.com/gergelyk/peepshow/master/docs/demo.gif)\n\n## Resources\n\n* Documentation: <https://gergelyk.github.io/peepshow>\n* Repository: <https://github.com/gergelyk/peepshow>\n* Package: <https://pypi.python.org/pypi/peepshow>\n* Author: [Grzegorz Kraso\u0144](mailto:grzegorz.krason@gmail.com)\n* License: [MIT](LICENSE)\n\n## Installation\n\nInstall `peepshow` package:\n\n```sh\npip install peepshow\n```\n\nPeepShow uses `clear`, `vim`, `man` commands which are available in most of Linux distributions. Users of other operating systems need to install them on their own.\n\n### Built-Ins\n\nIf you expect to use peepshow often, consider adding `peep` and `show` commands to Python's built-ins and enabling except hook. Edit either `{site-packages}/sitecustomize.py` or `{user-site-packages}/usercustomize.py` and append the following:\n\n```python\nimport peepshow\nimport builtins\nbuiltins.peep = peepshow.peep\nbuiltins.show = peepshow.show\nbuiltins.peep_ = peepshow.peep_\nbuiltins.show_ = peepshow.show_\npeepshow.enable_except_hook(consider_env=True)\n```\n\n### Breakpoint\n\nIt is also possible to invoke `peep()` as a result of calling built-in function `breakpoint()`. To enable such behavior use `PYTHONBREAKPOINT` system variable:\n\n```sh\nexport PYTHONBREAKPOINT=peepshow.peep\n```\n\n## Compatibility\n\n* This software is expected to work with Python 3.6, 3.7, 3.8 and compatible.\n* It has never been tested under operating systems other than Linux.\n* It works fine when started in a plain Python script, in ipython or ptipython.\n* In these environments like interactive python console, in pdb and ipdb, peep and show cannot infer names of the variables in the user context, so they need to be provided explicitly (e.g. use `peep_` and `show_`).\n\n## Usage\n\n### `show`\n\nRunning this script:\n\n```python\nx = 123\ny = {'name': 'John', 'age': 123}\nz = \"Hello World!\"\n\n# show all the variables in the scope\nshow()\n\n# or only variables of your choice\nshow(x, y)\n\n# you can also rename them\nshow(my_var=x)\n\n# use 'show_' to specify variable names as a string\nshow_('x')\n\n# expressions and renaming are also allowed\nshow_('x + 321', zet='z')\n```\n\nwill result in following output:\n\n```\nx = 123\ny = {'age': 123, 'name': 'John'}\nz = 'Hello World!'\nx = 123\ny = {'age': 123, 'name': 'John'}\nmy_var = 123\nx = 123\nx + 321 = 444\nzet = 'Hello World!'\n```\n\n### `peep`\n\nTry running the following script:\n\n```python\nx = 123\ny = {'name': 'John', 'age': 123}\nz = \"Hello World!\"\n\n# inspect dictionary that consists of all the variables in the scope\npeep()\n\n# or inspect variable of your choice directly\npeep(x)\n\n# use 'peep_' to specify variable name as a string\npeep_('x')\n```\n\nWhen interactive interface pops up:\n\n* Hit ENTER to see list of available variables.\n* Type `10` and hit ENTER to select `y`.\n* Hit ENTER again to see items of your dictionary.\n* Type `dir` and hit ENTER to list attributes of `y` (excluding built-ins).\n* Type `continue` and hit ENTER to proceed or type `quit` and hit ENTER to terminate your script.\n\nNote that all the commands have their short aliases. E.g. `quit` and `q` is the same.\n\nFor more help:\n\n* Type `help` and hit ENTER to see list of available commands.\n* Type `man` and hit ENTER to read the manual, hit `q` when you are done.\n\n### excepthook\n\nBefore running your script, set environment variable `PYTHON_PEEP_EXCEPTIONS` to `1`. Now run the script and see what happens when an exception is raised.\n\n## Development\n\n```sh\n# Preparing environment\npip install --user poetry # unless already installed\npoetry install\n\n# Testing with coverage\npoetry run pytest --cov peepshow --cov tests\n\n# Rendering documentation\npoetry run mkdocs serve\n\n# Building package\npoetry build\n\n# Releasing\npoetry version minor # increment selected component\ngit commit -am \"bump version\"\ngit push\ngit tag ${$(poetry version)[2]}\ngit push --tags\npoetry build\npoetry publish\npoetry run mkdocs build\npoetry run mkdocs gh-deploy -b gh-pages\n```\n\n## Donations\n\nIf you find this software useful and you would like to repay author's efforts you are welcome to use following button:\n\n[![Donate](https://www.paypalobjects.com/en_US/PL/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D9KUJD9LTKJY8&source=url)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python data explorer.",
"version": "0.3.0",
"project_urls": {
"Documentation": "https://gergelyk.github.io/peepshow",
"Homepage": "https://gergelyk.github.io/peepshow",
"Repository": "https://github.com/gergelyk/peepshow"
},
"split_keywords": [
"debug",
" data",
" explore",
" programming"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "61cb35d1ebc57b140e7a3e00157fd4af0d0b267e5d604c7d7c90bd195f39994e",
"md5": "0a0b91a3ff5a9ed5dd86999c18ea87f6",
"sha256": "0fb4b6dd0c8ec30283d351927e7bf85e8bc10bd0a75a9b1c563b2d18763cf096"
},
"downloads": -1,
"filename": "peepshow-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0a0b91a3ff5a9ed5dd86999c18ea87f6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.6",
"size": 30848,
"upload_time": "2024-12-14T19:31:08",
"upload_time_iso_8601": "2024-12-14T19:31:08.504708Z",
"url": "https://files.pythonhosted.org/packages/61/cb/35d1ebc57b140e7a3e00157fd4af0d0b267e5d604c7d7c90bd195f39994e/peepshow-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6195ecbf4be9dfbd0ab36128d6dcc10b3e3a82bce6effbfdebd3fcb729a00eaf",
"md5": "a809bc60d338752c70d377f0b496de2e",
"sha256": "24c9d97da6fce7b0981c1d097cc4b20821bdc059d939d7cda97d28cf5e1e5676"
},
"downloads": -1,
"filename": "peepshow-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "a809bc60d338752c70d377f0b496de2e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.6",
"size": 26093,
"upload_time": "2024-12-14T19:31:11",
"upload_time_iso_8601": "2024-12-14T19:31:11.075620Z",
"url": "https://files.pythonhosted.org/packages/61/95/ecbf4be9dfbd0ab36128d6dcc10b3e3a82bce6effbfdebd3fcb729a00eaf/peepshow-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-14 19:31:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gergelyk",
"github_project": "peepshow",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "peepshow"
}