PyScribe是一个Python库,可通过print语句进行调试程序更加方便简单和高效。
示例程序:
from pyscribe import pyscribedef main(): ps = pyscribe.Scriber() ps.save_logs(True) x = 5 ps.p(x) bar = "foo" for i in xrange(5): bar += str(i) ps.iterscribe(bar) y = "hello" ps.p(y) ps.watch(y) y = "world" foo = 1234 ps.d(foo) ps.d(foo, unit="^") synonyms = {"clerk": "secretary", "student": "apprentice", "ground": "floor"} ps.p(synonyms)if __name__ == "__main__": main()日志:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Log saved at 2014-12-31 22:03:48%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%From line 9: x is the int 5----------------------------------------bar is the str foo at beginning of for loop at line 12From line 14: In iteration 0, bar changed to foo0From line 14: In iteration 1, bar changed to foo01From line 14: In iteration 2, bar changed to foo012From line 14: In iteration 3, bar changed to foo0123From line 14: In iteration 4, bar changed to foo01234From line 17: y is the str helloFrom line 18: Watching variable y, currently str helloFrom line 20: y changed to worldFrom line 23: ----------------------------------------foo is the int 1234----------------------------------------From line 24: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^foo is the int 1234^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^From line 27: synonyms is the dict {'clerk': 'secretary', 'student': 'apprentice', 'ground': 'floor'}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%End of log%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
评论