title: Lock mutable objects as immutable in python
body: <p>How do I "lock" an object in Python?</p>
  
  <p>Say I have:</p>
  
  <pre><code>class Foo:
    def __init__(self):
      self.bar = []
      self.qnx = 10
  </code></pre>
  
  <p>I'd modify foo as much as I want:</p>
  
  <pre><code>foo = Foo()
  foo.bar.append('blah')
  foo.qnx = 20
  </code></pre>
  
  <p>But then I'd like to be able to "lock" it such that when I try</p>
  
  <pre><code>lock(foo)
  foo.bar.append('blah')  # raises some exception.
  foo.qnx = 20            # raises some exception.
  </code></pre>
  
  <p>Is that possible in Python?</p>