Hi,
Thanks for the responses. I understand that python automatically
sends 'self' to a member function, i.e. self gets prepended to the
argument list. I guess I am having trouble with this statement:
----
When the method object is called with an
argument list, it is unpacked again, a new argument list is
constructed from the instance object and the original argument list,
and the function object is called with this new argument list.
---
because I don't quite understand the timing. The "unpacked again"
part confuses me. If I have this code:
class MyClass:
def g(self, name):
print "Hello " + name
x = MyClass()
x.g("GvR")
here is what happens when I try to follow the sequence of events GvR
describes:
----------------
When an instance attribute is referenced that isn't a data attribute,
its class is searched.
x.g("GvR") ==> 'g' is not a data attribute, so class is searched.
If the name denotes a valid class attribute that is a function object,
a
method object is created by packing (pointers to) the instance object
and the function object just found together in an abstract object:
this is the method object.
==>method object is created
When the method object is called with an
argument list,
x.g("GvR") ==> I think I'm both "referencing an instance attribute"
and calling the method object with an argument list
it(the method object) is unpacked again, a new argument list is
constructed from the instance object and the original argument list,
and the function object is called with this new argument list.
??
--
http://mail.python.org/mailman/listinfo/python-list