摘要:
http://effbot.org/zone/python-with-statement.htmUnderstanding Python's "with"statementFredrik Lundh | October 2006 | Originally posted toonline.effbot.orgJudging from comp.lang.python and other forums, Python 2.5’s newwithstatementseems to be a bit confusing even for experienced Python 阅读全文
摘要:
http://jxfwinter.blog.163.com/blog/static/16465216920117911253659/python with语句的注解【摘】有一篇详细的介绍在:http://effbot.org/zone/python-with-statement.htm我简单翻译一下其中的要点:如果有一个类包含 __enter__ 方法和 __exit__ 方法,像这样:class controlled_execution: def__enter__(self): set things up returnthing def__exit__(self, type, value, 阅读全文