2014年12月26日金曜日

開発環境

Introducing Python: Modern Computing in Simple Packages(Bill Lubanovic (著)、 O'Reilly Media)のChapter 4(Py Crust: Code Structures)、Things to Do 4.11.を解いてみる。

Things to Do 4.11.

コード(BBEdit)

sample11.py

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

class OopsException(Exception): pass

try:
    raise OopsException('Caught an oops')
except OopsException as err:
    import sys
    print(sys.exc_info())
    print(err)

入出力結果(Terminal, IPython)

$ ./sample11.py
(<class '__main__.OopsException'>, OopsException('Caught an oops',), <traceback object at 0x103672708>)
Caught an oops
$

0 コメント:

コメントを投稿