[Tutor] methods and functions

Seabrook, Richard rhseabrook@aacc.edu
Fri Jun 13 11:04:22 2003



-----Original Message-----
From:	Gerardo Arnaez [mailto:garnaez@yahoo.com]
Sent:	Fri 6/13/2003 10:28 AM
To:	tutor
Cc:=09
Subject:	[Tutor] methods and functions
Hi sorry I made missed a word in what I was trying to
say



anyway, I had a discussion about it on irc.debian.org
#python and was surprised to learn that my thinking
methods were the same thing as functions WAS not
correct.. I was told
this was not the case, but every example I was given.
it looked to me that when a method was called for an
instance, it just like calling a function.

What is the difference?
where can I read to understand this point?

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
In OO-think:
Methods are pieces of code defined in a class and SHARED by
all objects (instances) of that class -- think of them as being
stored in a centralized, shared memory space.  Calling a method on
two different objects of the same class executes the SAME
set of machine language in memory.  It is the attribute (variable)
values that differ between objects and give them their unique
identity, so the attribute values can't be stored in the shared
methods but must reside elsewhere -- think of them as being in=20
the object.  So the object has to send along its address (self) in order =

for the shared code to process the correct values.  The shared code must
always use the self parameter to define or change values in the unique
object on which the method was called in order to create or
modify THAT OBJECT'S attribute values.
I hope all that makes sense...
Dick S.