Unification of Methods and Functions
Terry Reedy
tjreedy at udel.edu
Tue May 11 14:46:12 EDT 2004
More information about the Python-list mailing list
Tue May 11 14:46:12 EDT 2004
- Previous message (by thread): Unification of Methods and Functions
- Next message (by thread): Unification of Methods and Functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Antoon Pardon" <apardon at forel.vub.ac.be> wrote in message news:slrnca1d94.1i9.apardon at trout.vub.ac.be... > I don't see how this contradicts what I want to say. In both case you have > something of the form > > obj = cls() > > And in both obj.method() is equivallent to cls.method(obj) I believe Timothy's point was that inst.meth() is more general than any specific clas.meth(inst) whenever there is more than one possible meaning of 'clas'. In the following snippet, one can only replace 'animal.speak', without changing semantics, with 'animal.__class__.speak(animal)' and not with any specific versioon of clas.speak(animal). If something cannot be substituted without changing meaning, in a particular context, then, in that context, it literally does not mean the same thing. class mammal: def speak(self): print 'umf' class dog(mammal): def speak(self): print 'arf' class cat(mammal): def speak(self): print 'meow' for animal in [mammal(), dog(), cat()]: animal.speak() >>> umf arf meow >>> Terry J. Reedy
- Previous message (by thread): Unification of Methods and Functions
- Next message (by thread): Unification of Methods and Functions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list