Pdir2
Pretty dir() printing with joy:beer:
Install / Use
/learn @laike9m/Pdir2README
pdir2: Pretty dir() printing with joy
<a href="https://github.com/ambv/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
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.methodsto find all public own methods.You can also call
searchon 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.9if 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.
Related Skills
node-connect
349.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
