Entries Projects About

 Formatted dir (Python)

4 July 2017

Because I really like to use Python interactive mode when I write scripts, I made my own version of the dir function, because the standard dir function, while being very useful, is somewhat inconvenient.
I wrote it in a way that makes it possible to utilize it on Python 2 and 3. I tested it on Linux terminal, Windows command line and in IDLE.

Some screens with examples:

Linux Python 2.7
Formatted dir (Python)

Linux Python 3.5
Formatted dir (Python)

Windows cmd
Formatted dir (Python)

Windows IDLE
Formatted dir (Python)

The width of a column is always adjusted to the longest name in that particular column. The dunder methods are sorted separately from the rest. If you want the option of fast import of this function, you should add it to your libraries. In my case it's /usr/lib/python2.7, /usr/lib/python3.5 or C:\Python34\Lib in Windows.

Source code:
Github Formatted dir (Python)


Miscellaneous © 2014-2017-2018