[Tutor] methods and functions
Alan Gauld
alan.gauld@blueyonder.co.uk
Fri Jun 13 15:15:02 2003
> I'm with you. A method is a function. The differences lie
> in how each is found, and of course the first parameter
> is grabbed from "before the dot".
Sorry, I have to disagree. Within Python the similarities are
so great that you get away with thinking of them as identical
99% of the time but in theory, and in several languages in
practice too, there is a big difference between methods and
functions. Or more specifically there is a difference between
sending a message to an object and calling a function.
And under the covers that difference exists in Python too.
Once you start playing with the getattr methods you can change
the behaviour of an object quite a long way away from behaving
like a function call.
It is much better to get into the habit of thinking of passing
messages to objects and objects responding by executing a piece
of code - and which piece only the object knows...
Alan G.