언어&플랫폼/python 2015. 3. 24. 17:25


import traceback
import sys

try:
    do_stuff()
except Exception, err:
    print traceback.format_exc()


import sys, traceback

def run_user_code(envdir):
    source = raw_input(">>> ")
    try:
        exec source in envdir
    except:
        print "Exception in user code:"
        print '-'*60
        traceback.print_exc(file=sys.stdout)
        print '-'*60

envdir = {}
while 1:
    run_user_code(envdir)



python doc : 

https://docs.python.org/2/library/traceback.html


[펌]

http://stackoverflow.com/questions/3702675/print-the-full-traceback-in-python-without-halting-the-program

'언어&플랫폼 > python' 카테고리의 다른 글

[python] crontab 요약  (0) 2015.03.25
[python] 파이썬 로깅모듈 (펌)  (0) 2015.03.24
[python] config 설정 요약(ConfigParser)  (0) 2015.03.17
[python] 리스트 랜덤 선택  (0) 2015.01.20
[python] time 관련  (0) 2015.01.06
posted by cozyboy
: