看最后一段代码
begin
file = open("/tmp/some_file", "w")
# ... write to the file ...
rescue
# ... handle the exceptions ...
ensure
file.close # ... and this always happens.
end ensure的异常处理条件是,无论如何,这个异常一定要处理,那么,他在这里加上了file.close,如果在file.open的时候出现问题,或者是找不到文件呀之类的异常条件,那么open方法就没有执行,那又何来的close呢?这不是错上加错吗?