Skip to main content

Pretty dir printing with joy

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdir2-0.3.4.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdir2-0.3.4-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file pdir2-0.3.4.tar.gz.

File metadata

  • Download URL: pdir2-0.3.4.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for pdir2-0.3.4.tar.gz
Algorithm Hash digest
SHA256 67ed9b97dd9fadc6eddd5d1a088c958b5464035f1f718563f8ccf98b2c116a21
MD5 85e7e0c49b8a8e7398644de35913d211
BLAKE2b-256 aec93da9b4124edc25a2242cb2447a71fd057e73062556da248a037e5cc81911

See more details on using hashes here.

File details

Details for the file pdir2-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: pdir2-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for pdir2-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 81ecdd13104dd610ca268316499aea96a3693cb49f34f053348cb5abc5ad62d0
MD5 70eeab423e72cf1b84fdf462f877e351
BLAKE2b-256 e61f1b15899484372da8410e1121e5ac9b7dbf45a135c460c788b82fe83c96d4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page