title: Why does assigning to self not work, and how to work around the issue?
body: <p>I have a class (list of <code>dict</code>s) and I want it to sort itself:</p>
  
  <pre><code>class Table(list):
  …
    def sort (self, in_col_name):
      self = Table(sorted(self, key=lambda x: x[in_col_name]))
  </code></pre>
  
  <p>but it doesn't work at all. Why? How to avoid it? Except for sorting it externally, like:</p>
  
  <pre><code>new_table = Table(sorted(old_table, key=lambda x: x['col_name'])
  </code></pre>
  
  <p>Isn't it possible to manipulate the object itself? It's more meaningful to have:</p>
  
  <pre><code>class Table(list):
    pass
  </code></pre>
  
  <p>than:</p>
  
  <pre><code>class Table(object):
    l = []
    …
    def sort (self, in_col_name):
      self.l = sorted(self.l, key=lambda x: x[in_col_name])
  </code></pre>
  
  <p>which, I think, works.
  And in general, isn't there <em>any</em> way in Python which an object is able to change itself (not only an instance variable)?</p>