title: What's the Pythonic way to write an auto-closing class?
body: <p>I'm a noob with Python, but I've written an auto-close function like this..</p>
  
  <pre><code>@contextmanager
  def AutoClose(obj):
      try:
          yield obj
      finally:
          obj.Close()
  </code></pre>
  
  <p>I have three classes that have a Close() method that this function can be used with.  Is this the most Pythonic solution?  Should I be doing something in the classes themselves instead?</p>