• Stars
    star
    1,320
  • Rank 35,625 (Top 0.8 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pretty dir() printing with joy🍺

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.

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

Development

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.

More Repositories

1

Cyberbrain

Python debugging, redefined.
Python
2,503
star
2

Python-Type-Challenges

Master Python typing (type hints) with interactive online exercises!
Python
499
star
3

PyPunchP2P

Python实现NAT穿透+STUN+TURN+P2P聊天 | Python P2P chat
Python
434
star
4

My_Blog

My Django Blog
HTML
213
star
5

Cyberbrain-Deprecated

[Deprecation] This project has been deprecated. Development moved to github.com/laike9m/Cyberbrain
Python
166
star
6

ezcf

Import configuration file for Pythonista
Python
159
star
7

zhihu-card

用卡片在个人网站上展示知乎账户
CSS
121
star
8

rsshub-zhihu-helper

如果你希望通过 RSSHub 浏览知乎,那么这个项目或许可以帮到你。
Python
70
star
9

Bad-Apple-Console

ASCII Art: Bad 🍎 in Windows console
C++
42
star
10

logseq-chatgpt

Talk to ChatGPT directly from Logseq
JavaScript
34
star
11

f

Log to a file without modifying code, with just one line 📝
Python
19
star
12

peerjs-with-nodewebkit-tutorial

How to integrate PeerJs into node-webkit/NW.js app
JavaScript
11
star
13

split_p

漫画图片分割 | split images for manga reading
Python
11
star
14

all_in_utf8

Recursively find and convert files to utf8 encoding
Python
5
star
15

VideoChat

elgg video chat plugin / elgg 视频通话插件
PHP
4
star
16

learn_socket

Learn Python socket programming
Python
3
star
17

CU_login

ChinaUnicom 自动登录断线重连
Python
3
star
18

Xylect

One-click AI search & translation, anywhere in your Mac
3
star
19

logseq-twitter-sync

JavaScript
2
star
20

MusicService

读取mp3生成markdown格式的音乐列表
Python
2
star
21

DataMining

DataMining Project
Python
1
star
22

spk_cmp2methods

compare 2 methods of speaker change detection
Python
1
star
23

h2-playground

Python
1
star
24

mysite1

My Django Project,consisting of my personal blog and the Mike Hilbert's tutorial things
Python
1
star
25

train

Python
1
star
26

Algorithm_homework_code

Python
1
star
27

pipAlwaysLatest

A wrapper around pip, install/generate requirements with the latest version
Python
1
star
28

Slides

HTML
1
star
29

cyberbrain-examples

Python
1
star
30

DumpRenrenPosts2Markdown

人人日志导出工具/Dump Renren Posts to Markdown
Python
1
star