title: Resetting class to default state
body: <p>In Python, what is standard/commonly used way to reset class to "default state"? For example, before loading something to class you might want to reset existing data.</p>
  
  <p>For example, check out <code>self.clear()</code> method below:</p>
  
  <pre><code>class ConLanguage:
      SERIALIZABLE_ATTRIBUTES = \
          ["roots", "prefixes", "suffixes"...] #list of "important" fields
  
      def __init__(self):
          self.roots = []
          self.prefixes = []
          self.suffixes = []
          .....
  
      def clear(self): # &lt;&lt;--- this method
          tmp = ConLanguage()
          for attr in self.SERIALIZEABLE_ATTRIBUTES:
              setattr(self, attr, getattr(tmp))
  
      def loadFromDict(self, inDict):
          defaultValues = ConLanguage()
          for attr in self.SERIALIZABLE_ATTRIBUTES:
              setattr(self, attr, inDict.get(attr, getattr(defaultValues.attr)))
  
      def loads(self, s):
          self.loadFromDict(json.loads(s))
  </code></pre>
  
  <p>This approach seems to do the job, but I wonder if there is another way to do it.</p>
  
  <hr>
  
  <p>The <a href="https://stackoverflow.com/questions/2116090/python-class-attributes-resetting">other question</a> (which does not have accepted answers) seems to cover diferrent problem - it has couple of numerical fields that needs to be all initialized with zero, while in this scenario there are bunch of members that have different default state - dictionaries, arrays, numbers, strings, etc. </p>
  
  <p>So it was less about "how do I iterate through class attributes" and more about: "does python have commonly used paradigm for this particular situation". Accessing attributes by their names using strings doesn't seem quite right.</p>