exceptionを見やすく
http://melpystudio.blog82.fc2.com/blog-entry-87.html
import sys, traceback
try:
# エラーとなる行
text == 'Miss'
except:
# エラーの情報をsysモジュールから取得
info = sys.exc_info()
# tracebackモジュールのformat_tbメソッドで特定の書式に変換
tbinfo = traceback.format_tb( info[2] )
# 収集した情報を読みやすいように整形して出力する----------------------------
print 'Python Error.'.ljust( 80, '=' )
for tbi in tbinfo:
print tbi
print ' %s' % str( info[1] )
print '\n'.rjust( 80, '=' )
# -----------------------------------------------------------------------------------
Python Error.===================================================================
File "<maya console>", line 4, in <module>
name 'text' is not defined
===============================================================================</module>