pythonでprint_rしてみる

phpのprint_rはデバッグ時に便利ですが残念ながらpythonにはないようです。
ライブラリがあったので試してみました。
まぁデバッグなぞひたすらprintでやってもいいのですけどね


windows環境です
1. ここの右上のDownload Sourceからzipファイルをダウンロードする
2. ダウンロードしたファイル適当なフォルダに解凍して、コマンドラインから次のコマンドを実行
 > python setup.py install

3. 使い方

test.py

from print_r import print_r

hoge = ['aaa', 'bbb', 'ccc', {'test1': 'dic test1', 'test2': 'dic test2'}]
print_r(hoge)

実行する

> python test.py

結果
0 = aaa
1 = bbb
2 = ccc
3 = <type 'dict'>
    test1 = dic test1
    test2 = dic test2