Title: PDB enhancement
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Jim Fasarakis-Hilliard, Sergey.Kirpichev, erixoltan, rhettinger
Priority: normal Keywords:

Created on 2017-04-18 18:32 by erixoltan, last changed 2021-04-23 08:41 by Sergey.Kirpichev.

File name Uploaded Description Edit erixoltan, 2017-04-18 18:32 Patched modification of that introduces a new ppp command
Messages (2)
msg291839 - (view) Author: Erik Zoltan (erixoltan) Date: 2017-04-18 18:32
I have created a pdb enhancement that allows me to query an object's internals more gracefully. It is incredibly useful and it would be very easy to include this logic in the distribution version of pdb. 

I created my own modification of pdb called zdebug (attached as that implements a new ppp debugging command. This command prints a formatted output of an object's internals. It could be smoother, and doesn't fully obey the programming conventions used with in pdb, and I'm not proposing to submit it as a patch. However the ppp command is pretty simple and incredibly useful.  

Here's a tiny example. I can drill into an object, see its internals, and interactively explore its property chain. (The zdebug.zbreak() call is equivalent to pdb.set_trace()). 

$ python3
>>> from datetime import date
>>> today =
>>> import zdebug
>>> zdebug.zbreak()
> <stdin>(1)<module>()->None
zdebug> p today, 4, 18)
zdebug> ppp today
   ctime = <built-in method ctime of object at 0x7fc688a1cf50>
   day = 18
   fromordinal = <built-in method fromordinal of type object at 0x562b84a60d60>
   fromtimestamp = <built-in method fromtimestamp of type object at 0x562b84a60d60>
   isocalendar = <built-in method isocalendar of object at 0x7fc688a1cf50>
   isoformat = <built-in method isoformat of object at 0x7fc688a1cf50>
   isoweekday = <built-in method isoweekday of object at 0x7fc688a1cf50>
   max = 9999-12-31
   min = 0001-01-01
   month = 4
   replace = <built-in method replace of object at 0x7fc688a1cf50>
   resolution = 1 day, 0:00:00
   strftime = <built-in method strftime of object at 0x7fc688a1cf50>
   timetuple = <built-in method timetuple of object at 0x7fc688a1cf50>
   today = <built-in method today of type object at 0x562b84a60d60>
   toordinal = <built-in method toordinal of object at 0x7fc688a1cf50>
   weekday = <built-in method weekday of object at 0x7fc688a1cf50>
   year = 2017

zdebug> p
zdebug> p today.year
msg291840 - (view) Author: Jim Fasarakis-Hilliard (Jim Fasarakis-Hilliard) * Date: 2017-04-18 19:30
Dunno, if I wanted to see a nice formatted output of the internals I'd run `pp vars(obj)`. 

That, though, suffers a bit from the fact that `vars` is not the most known of the builtins.
Date User Action Args
2021-04-23 08:41:30Sergey.Kirpichevsetnosy: + Sergey.Kirpichev
2017-04-18 22:13:20rhettingersetnosy: + rhettinger
2017-04-18 19:30:58Jim Fasarakis-Hilliardsetnosy: + Jim Fasarakis-Hilliard

messages: + msg291840
versions: + Python 3.7, - Python 3.5
2017-04-18 18:32:36erixoltancreate