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():
- 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 --or-- dnf install python2-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!
Testing
Simply run pytest, or use tox if you like.
Release History
0.3.0(2018-02-10)
Add support for various filters (#37)
0.2.0(2017-04-04)
Add support for color customization. (#14)
0.1.0(2017-03-16)
Add support for ipython, ptpython and bpython (#4)
0.0.2(2017-03-11)
API Changes (Backward-Compatible)
Added a case_sensitive parameter into the search function (#5)
Bugfixes
Error calling pdir(pandas.DataFrame) (#1)
Methods are now considered functions (#6)
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
Hashes for pdir2-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33c7242f67d9845b2921551dfb58c8cedc0160c23a6f7c48dacf824a01ca052b |
|
MD5 | 54ee4747c69004ac024800c518ce875c |
|
BLAKE2b-256 | 790fec8f0fca12a2bf70ed6cbca7e1e0dcc51154a5487eba40566996688c68ec |