Skip to main content

:warning: On master branch, pdir2's codebase is Python 3.5+, with annotations and mypy check. The Python 2 compatible version exists 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

Build Status Supported Python versions PyPI Version Code style: black

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
--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.

Developement

Clone the source, run make install_dev_packages.
Don't forget to add proper type annotations, if you're not sure what to do, check out the gen_type_info section in tox.ini.

Release History

0.3.1(2018-10-25)

  • Add support for __slots__ (#44, #45)
  • Seperate @staticmethod with other descriptors(#38, #42)
  • Add __post_init__ support

Special thanks to @liwt31 for his great contribution.

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)

Release files for pdir2 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdir2 0.3.2
File Size Uploaded
pdir2-0.3.2.tar.gz 14.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdir2 0.3.2
File Interpreter ABI Platform
pdir2-0.3.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 27.9 kB

Release files / pdir2-0.3.2.tar.gz

Download URL pdir2-0.3.2.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
26d7459a5d994cedbfb3f2c2460c8e1fe3741c6db9b69791409b13563b91d5e3
BLAKE2b-256 checksum
How to use checksums
3bfde4cf1a5262058868b21fb2f244ecf6e378052b46b77dc951bfbf344d1ffb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0

Release files / pdir2-0.3.2-py2.py3-none-any.whl

Download URL pdir2-0.3.2-py2.py3-none-any.whl
Size 13.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9d3300e1704df359102c3ce8f92bd615155e348258809954ac868932ee03cff3
BLAKE2b-256 checksum
How to use checksums
25df78657e25574db75474ca898e49d0e892a70e82a3eea6221694323098901b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.9.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page