[Tutor] Re: More Class Help.
Emile van Sebille
emile@fenx.com
Tue, 20 Aug 2002 06:56:16 -0700
"S A" <buc40@bemail.org> wrote in message
news:200208200503.g7K53qu09430@mail19.bigmailbox.com...
> Hi Everyone-
>
> Let's say I have the following made up class:
>
> class MadeUp:
> def __init__(self, x, y, z):
> self.x = x
> self.y = y
> self.z = z
>
> def xData(self, x):
> ... do some stuf here...
> def yData(self, y):
> ... do some stuf here...
> def zData(self, z):
> ... do some stuf here...
>
> Would this allow a person to pass along the variables (x,y,z) to the
the "MadeUp" instance?
Yes, if what you mean is:
myMadeUpInstance = MadeUp(x,y,z)
> Would this also allow someone to pass the variables along to each of
the class methods?
>
The __init__ method saves x,y & z as attributes of self. The other
methods can access self. So I suspect what you want is more like:
def xData(self):
... do stuff with self.x here
... using self.y and self.z as needed
HTH,
--
Emile van Sebille
emile@fenx.com
---------