Scott David Daniels wrote:
I wrote:
In PythonOOP.doc (page 4) you say:
> There are two pieces of "magic" that make line 3 work. First, the
> interpreter has to find the method set_vars. It's not in cat2. Then,
> the instance cat2 has to be inserted as the first argument to et_vars.
> The method is found by a search starting at cat2 ( the instance on
> which the method is called ). The search then proceeds to the parent
> class, then to the grandparent, and so on up to object, the ancestor
> of all Animal classes. In this case, we find set_vars in Cat.
For instances of subclasses of object (such as Cat), method lookups
start in Cat, not cat2. If you try to set cat2.set_vars, you cannot
(because a method is a property stored in he class), and you will try
the set method of that property which will fail. Simple class variables
are over-ridden by assignments to the instance values, but properties
are not.
And then immediately went to make a test case, which failed. Which
I should, of course, done before hitting send. I retract my comment
and will get back to you when I get my understanding straightened out.
--Scott David Daniels
[email protected]
_______________________________________________
Edu-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/edu-sig