 <p>The error occurs when the default value is evaluated. This happens when the class is being defined (not when the method is called). At that point in time, <code>self</code> has no meaning.</p> <p>One way to fix this is like so:</p> <pre><code> ... def foo2(self,aa=None): if aa is None: aa = self.A return "la" ... </code></pre>