Giter Site home page Giter Site logo

pdir2's Introduction

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!

Development

  1. Set up development environment

    • PDM: pdir2 uses PDM to manage dependencies, so you want to make sure it's installed.
    • pyenv: Since you need to test pdir2 on multiple Python versions, pyenv is highly recommended. Make sure you have Python 3.8, 3.9, 3.10 and 3.11 installed.
  2. 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.9 if you want to debug a Python 3.9 specific issue).

  3. Run tests

    Run pdm run tox

The guide may be incomplete. Please file bugs if you encounter any issues.

pdir2's People

Contributors

laike9m avatar liwt31 avatar carlwgeorge avatar kshivakumar avatar laixintao avatar iamgodot avatar kapsh avatar mdraw avatar frostming avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.