Re:Implementing Go's defer keyword in C++
by masklinn on Sunday October 22, 2017 @06:24AM
(#15526037)
On the other hand, it means any helper/builder has to handle this pattern on its own rather than be able to return a file object which can be "context managed" by a caller, which Python allows.
[ Parent
| on HN ]
True, but it's fairly easy to write:
def self.open
File.open(...) { |f| yield f }
end
Unless they need custom destructor actions, in which case presumably they'd have to implement that manually in python too.