Dave Hansen a écrit : (snip) > As others have mentioned, you can also provide local synonyms if the > dot syntax is too onerous. But make sure you use the member access > syntax if the result of an expression is an immutable type. For > example, I assume a_dot is a mutable type, such as a list. If so, > then you could simply use > > a_dot, k, a, u = self.a_dot, self.k, self.a, self.u > a_dot = -k(a-u) > > However, if it's an immutable type, such as a scalar, strung, or > tuple, you need > > self.a_dot = -k(a-u)
Hmmm... Actually, whether self.a_dot is an instance of a mutable or immutable type won't change anything - in both case, it's only the *local* name a_dot that'll be rebound. So <op> as soon as you want to rebind (iow:assign to) an attribute, you *need* to use self.the_attr_name on the LHS. Of course, *mutating* is a different situation... -- http://mail.python.org/mailman/listinfo/python-list