Python - デバッグ - オブジェクトの中身を見る

 クラウディア
1. 概要
2. オブジェクトの中身を見る

1. 概要

 ほぼ、前ページの続きになるのですが。  「self」という変数があって、それを見ようとすると

(Pdb) p self
<Prophet.Desktop.App object at 0x8019baf98>
 てなことになる。  「self」自体は、「Prophet.Desktop.App」のオブジェクトで、アドレスが「0x8019baf98」なのだろうが、中身が何だか知りたいわけです。  「Pythonでインスタンスの状態をダンプするにはvars()を使う - minus9d's diary」が参考になりました。  ありがとうございます。

2. オブジェクトの中身を見る


print(vars(変数名))
 でいいんですって。

(Pdb) print(vars(self))
{'desktop': {'Version': '1.0', 'Terminal': 'false', 'NoDisplay': 'false', 'Hidden': 'false', 'Icon': 'libreoffice-startcenter', 'Type': 'Application', 'Categories': ('Office', 'X-Red-Hat-Base', 'X-SuSE-Core-Office', 'X-MandrivaLinux-Office-Other'), 'Exec': 'libreoffice %U', 'MimeType': ('application/vnd.openofficeorg.extension', 'x-scheme-handler/vnd.libreoffice.cmis'), 'Name': 'LibreOffice', 'GenericName': 'Office', 'Comment': 'The office productivity suite compatible to the open and standardized ODF document format. Supported by The Document Foundation.', 'StartupNotify': 'true', 'X-GIO-NoFuse': 'true', 'StartupWMClass': 'libreoffice-startcenter', 'X-KDE-Protocols': 'file,http,ftp,webdav,webdavs', 'Actions': ('Writer', 'Calc', 'Impress', 'Draw', 'Base', 'Math')}, 'exename': 'libreoffice', 'keywords': Set({'X-MandrivaLinux-Office-Other', 'Office', 'X-SuSE-Core-Office', 'X-Red-Hat-Base'}), 'execmd': 'libreoffice'}
 ををを、見えましたわん。