Pretty dir printing with joy
:warning: pdir2 will soon switch to a codebase that only supports Python 3.5+, because I want to add type hints and apply those cool toolings like mypy. The Python 2 compatible version will exist in the 0.3.x branch, and will still be receiving bug fixes. All new features will be developed on master therefore is Python 3.5+ exclusive.
In short, if you're still using pdir2 for Python <3.5, install via
pip install "pdir2>=0.3,<0.4".
pdir2: Pretty dir() printing with joy
Have you ever dreamed of a better output of
dir()? I do. So I created this.
Attributes are grouped by types/functionalities, with beautiful colors.
Support color customization, here's how.
Support all platforms including Windows(Thanks to colorama).
The return value of
pdir()can still be used as a list of names.
✨ Attribute searching
You can search for certain names with
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.methodsto find all public own methods.
You can also call
searchon the returned results.
See a complete example.
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.
dnf install python3-pdir2 --or-- dnf install python2-pdir2
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
.zshrc), add this line:
.pythonstartup in your home folder. Add one line:
Next time you launch REPL,
pdir() is already there, Hooray!
pytest, or use
tox if you like.
- Add support for
@staticmethodwith other descriptors(#38, #42)
Special thanks to @liwt31 for his great contribution.
- Add support for various filters (#37)
- Add support for color customization. (#14)
- Add support for ipython, ptpython and bpython (#4)
API Changes (Backward-Compatible)
- Added a
case_sensitiveparameter into the
- Error calling pdir(pandas.DataFrame) (#1)
- Methods are now considered functions (#6)
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pdir2-0.3.1.post2-py2.py3-none-any.whl (13.6 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size pdir2-0.3.1.post2.tar.gz (13.0 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for pdir2-0.3.1.post2-py2.py3-none-any.whl