different types of inheritence...
zipher
dreamingforward at gmail.com
Wed May 27 14:12:07 EDT 2015
On Tuesday, May 26, 2015 at 3:53:25 PM UTC-5, Michael Torrie wrote:
> On 05/26/2015 08:57 AM, zipher wrote:
> > Comprende? I'm not trying to be cryptic here. This is a bit of OOP
> > theory to be discussed.
>
> No, sorry. Maybe an actual example (with use case) would spur discussion.
In the first example, super_dict changes the behavior of <dict> *for the user*, expanding the API, but keeping all the prior method behaviors the same.
In the second example, specialized_dict changes the behavior in the machine -- the API stays the same so the user of the code just gets new benefits from whatever the specialized_dict is improving internally *without changing his/her code*. It's a drop-in replacement.
In other words, the second class changes the INTERNALS of <dict>. While the first class changes the *externals* of <dict>. Yet they both use the same class definition, but semantically are completely different. It's TWO different definition of IS-A relationship. Two definitions of the word "is".
m
More information about the Python-list
mailing list