with
with_statement ってあんまり知られてないなぁ。Python 2.5 からだけど。
from __future__ import with_statement import sys with file(sys.argv[0], 'r') as fp: for line in fp: sys.stdout.write(line)
with のブロックに入った直後に __enter__ が、ブロックをでるときに(例外があれば例外の情報付きで) __exit__ が呼ばれる。で、例外発生時に __exit__ が true を返すと、例外抑制、true 以外を返すと例外が再 raise。
from __future__ import with_statement import sys class foo(object): def __enter__(self): print 'enter' def __exit__(self, *excinfo): print 'exit %s' % repr(excinfo) return True for i in range(3): with foo() as f: print 'content' if i == 1: raise Exception() if i == 2: break
特許とか著作権とか
- ref:http://blog.ememo.jp/2007/10/post_14.html
- ref:http://b.hatena.ne.jp/entry/http://blog.ememo.jp/2007/10/post_14.html
- ref:http://d.hatena.ne.jp/banraidou/20071015/1192425843
- ref:http://b.hatena.ne.jp/entry/http://d.hatena.ne.jp/banraidou/20071015/1192425843
いやいやいや、公知という点を差し引いてもこんなん特許の保護対象外だろ。特許、著作権以外のなんらかの知的財産権ではなんとかなるかもしれんが。
特許法第2条より
この法律で「発明」とは、自然法則を利用した技術的思想の創作のうち高度のものをいう。