Why self?

Alex Martelli aleax at aleax.it
Tue Jul 9 17:35:16 EDT 2002


Robb Shecter wrote:

> Alex Martelli wrote:
>>... And the reason you don't have to state that, is that it makes
>>absolutely
>> no difference whatsoever -- you can try to get any attribute (methods
>> included) from any object, it either succeeds or fails (and that only
>> partly depends on the object's class).
> 
> Well, I'd say that an object understanding the message I send to it, or
> being the type of object I think it is - success or failure - surely is
> a big difference!  Sort of the name of the whole game...

An object can "understand" (well...) the message (out of metaphor: be
able to supply the attribute or method you're asking of it) WITHOUT
"being the type you think it is".  This is called POLYMORPHISM, and
IS the whole game.


Alex




More information about the Python-list mailing list