title: How to restrict setting an attribute outside of constructor?
body: <p>I want to forbid further assignments on some attributes of a class after it was initialized. For instance; no one can explicitly assign any value to 'ssn' (social security number) property after the Person instance 'p' has been initialized. <strong>_<em>setattr</em>_</strong> is also being called while assigning the value inside <strong>_<em>init</em>_</strong> method, thus it is not what I want. I'd like to restrict only further assignments. How can I achieve that?</p>
  
  <pre><code>class Person(object):
      def __init__(self, name, ssn):
          self.name = name
          self._ssn = ssn
  
      def __setattr__(self, name, value):
          if name == '_ssn':
              raise AttributeError('Denied.')
          else:
              object.__setattr__(self, name, value)
  
  &gt;&gt; p = Person('Ozgur', '1234')
  &gt;&gt; AttributeError: Denied.
  </code></pre>