This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PDB enhancement
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.7
process
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 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
zdebug.py erixoltan, 2017-04-18 18:32 Patched modification of pdb.py 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 zdebug.py) 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 = date.today()
>>> import zdebug
>>> zdebug.zbreak()
--Return--
> <stdin>(1)<module>()->None
zdebug> p today
datetime.date(2017, 4, 18)
zdebug> ppp today
   ctime = <built-in method ctime of datetime.date 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 datetime.date object at 0x7fc688a1cf50>
   isoformat = <built-in method isoformat of datetime.date object at 0x7fc688a1cf50>
   isoweekday = <built-in method isoweekday of datetime.date object at 0x7fc688a1cf50>
   max = 9999-12-31
   min = 0001-01-01
   month = 4
   replace = <built-in method replace of datetime.date object at 0x7fc688a1cf50>
   resolution = 1 day, 0:00:00
   strftime = <built-in method strftime of datetime.date object at 0x7fc688a1cf50>
   timetuple = <built-in method timetuple of datetime.date object at 0x7fc688a1cf50>
   today = <built-in method today of type object at 0x562b84a60d60>
   toordinal = <built-in method toordinal of datetime.date object at 0x7fc688a1cf50>
   weekday = <built-in method weekday of datetime.date object at 0x7fc688a1cf50>
   year = 2017

zdebug> p today.day
18
zdebug> p today.year
2017
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.
History
Date User Action Args
2022-04-11 14:58:45adminsetgithub: 74280
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