title: Python - how to clear class variables automatically when class variables are resource
body: <p>I have a problem with dealing with class variables in Python. I have a code as the following.</p>
  
  <pre><code>class TempClass:
      resource = xlwings.Book() # xlwings is a library manipulating Excel file.
  
      #...
  </code></pre>
  
  <p>Here, to clear 'resource', I need to execute</p>
  
  <pre><code>resource.close()
  </code></pre>
  
  <p>Is there any built-in function called when a class (not object) is cleared, so that I can write the above code in that function? Or is there any way to clear 'resource'?</p>
  
  <p>My Python version is 3.6</p>