self argument
Mikael Olofsson
mikael at isy.liu.se
Mon Feb 28 07:25:30 EST 2000
On 28-Feb-00 Gregoire Welraeds wrote:
> In reply to the message of James Logajan sent on Feb 26 (see below) :
>
> In my newbiness ignorance, I'm asking what is the difference between t and
> self.x. Aren't they both member of the class C ?
>
> > class C:
> > def __init__(self, b):
> > self.b = b
> > self.x = self.y = 0
> > def Func(self, a):
> > t = a * self.b
> > self.x = t * 2
> > self.y = t + 2
No, t is a local variable in C.Func, while self.x refers to a member.
Thus, if you have an instance c of class C, there will never be a c.t,
but there is a c.b, a c.x, and a c.y.
/Mikael
-----------------------------------------------------------------------
E-Mail: Mikael Olofsson <mikael at isy.liu.se>
WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael
Phone: +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date: 28-Feb-00
Time: 13:19:32
This message was sent by XF-Mail.
-----------------------------------------------------------------------
More information about the Python-list
mailing list