Nikolaus Rath wrote: > No, but it could work like this: > > def a(x, y): > self.x = x > self.y = y >
Frankly this would make reading and debugging the code by a third party to be a nightmare. Rather than calling the variable self as I did in my example, I could it in a much better way: def method(my_object, a, b): my_object.a = a my_object.b = b Now if I saw this function standalone, I'd immediately know what it was doing. In fact, I can even unit test this function by itself, without even having to know that later on it's monkey-patched into an existing class. With your idea, I might get the picture this function should be used as a method in some object because of the self reference, but I can't test the method by itself. Trying to call it would instantly result in an exception. And if this was a large function, I might not even see the self reference right away. -- http://mail.python.org/mailman/listinfo/python-list