Pretty dir printing with joy
Project description
pdir2: Pretty dir() printing with joy
Have you ever dreamed of a better output of dir()
? I do. So I created this.
Features
-
Attributes are grouped by types/functionalities, with beautiful colors.
-
Support color customization, here's how.
-
Support all platforms including Windows(Thanks to colorama).
-
Support ipython, ptpython, bpython and Jupyter Notebook! See wiki for details.
-
The return value of
pdir()
can still be used as a list of names. -
✨ Attribute searching
You can search for certain names with
.s()
or.search()
:Search is case-insensitive by default.
search(name, case_sensitive=True)
does case-sensitive searching. -
:star2: Attribute filtering
properties
: Find properties/variables defined in the inspected object.methods
: Find methods/functions defined in the inspected object.public
: Find public attributes.own
: Find attributes that are not inherited from parent classes.These filters can be chained! Order does NOT matter.
For example, use
pdir(obj).public.own.methods
to find all public own methods.You can also call
search
on the returned results.See a complete example.
Install
Generic
pip install pdir2
About the name. I wanted to call it "pdir", but there's already one with this name on pypi. Mine is better, of course.
Fedora
dnf install python3-pdir2
Automatic Import
As a better alternative of dir()
, it's more convenient to automatically import
pdir2 when launching REPL. Luckily, Python provides a way to do this. In you .bashrc
(or .zshrc
), add this line:
export PYTHONSTARTUP=$HOME/.pythonstartup
Then, create .pythonstartup
in your home folder. Add one line:
import pdir
Next time you launch REPL, pdir()
is already there, Hooray!
Development
-
Set up development environment
-
Install dev dependencies
Simply run
pdm install
.If you want to work on a specific Python version, run
pdm use [PYTHON_VERSION]
first to switch PDM to that version (e.g.pdm use 3.9
if you want to debug a Python 3.9 specific issue). -
Run tests
Run
pdm run tox
The guide may be incomplete. Please file bugs if you encounter any issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pdir2-1.1.1.tar.gz
.
File metadata
- Download URL: pdir2-1.1.1.tar.gz
- Upload date:
- Size: 19.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e06de82af0b94764d70625fc837d02e11c85c867ae90723a61e08ecefd9d2d1f |
|
MD5 | c707f13cedb9719c3249edff44acfbca |
|
BLAKE2b-256 | 514d92bd6f67a59de3a5675f2944a9c0b8e5c075131cc703a4cae96391c247fb |
File details
Details for the file pdir2-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: pdir2-1.1.1-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e19203a14774993b9df825845b69f87a9302d6e848f975b8ea3ddf2f7449c410 |
|
MD5 | 66270a4fb3eebf83f6c5346ead8d6ca5 |
|
BLAKE2b-256 | 09be47ca45dfc479b16e5ec9bf6c502173ca8500b3e8cd003c7864dc6a43ef69 |