[Tutor] self parameter

Katharine Stoner kstoner@netins.net
Wed, 9 May 2001 22:26:27 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C0D8D7.16AEDA20
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I am trying to understand how special methods work.
Ex:
class now:
def _init_(self):
    self.t =3D time.time()
    self.year, \
    self.month, \
    self.day, \
    self.hour, \
    self.minute, \
    self.second, \
    self.dow, \
    self.doy, \
    self.dst =3D time.localtime(self.t)
I don't know if I got it right, but I think the function is passing data =
to each variable, t; year; month; etc.  It's unpacking the tuple.  I'm =
not sure I understand how this bit of code is working.  The self =
arguement is allowing the function to pass data right?
I'd much appreciate any assistance.
-Cameron

------=_NextPart_000_000D_01C0D8D7.16AEDA20
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I am trying to understand how special =
methods=20
work.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Ex:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>class now:<BR>def=20
_init_(self):<BR>&nbsp;&nbsp;&nbsp; self.t =3D =
time.time()<BR>&nbsp;&nbsp;&nbsp;=20
self.year, \<BR>&nbsp;&nbsp;&nbsp; self.month, \<BR>&nbsp;&nbsp;&nbsp; =
self.day,=20
\<BR>&nbsp;&nbsp;&nbsp; self.hour, \<BR>&nbsp;&nbsp;&nbsp; self.minute,=20
\<BR>&nbsp;&nbsp;&nbsp; self.second, \<BR>&nbsp;&nbsp;&nbsp; self.dow,=20
\<BR>&nbsp;&nbsp;&nbsp; self.doy, \<BR>&nbsp;&nbsp;&nbsp; self.dst =3D=20
time.localtime(self.t)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I don't know if I got it right, but I =
think the=20
function is passing data to each variable, t; year; month; etc.&nbsp; =
It's=20
unpacking the tuple.&nbsp; I'm not sure I understand how this bit of =
code is=20
working.&nbsp; The self arguement is allowing the function to pass data=20
right?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I'd much appreciate any =
assistance.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>-Cameron</FONT></DIV></BODY></HTML>

------=_NextPart_000_000D_01C0D8D7.16AEDA20--