[Tutor] sending data

wheelege wheelege@tsn.cc
Wed, 16 May 2001 14:16:07 +1000


This is a multi-part message in MIME format.

------=_NextPart_000_00D9_01C0DE12.C00B0860
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


  Well, saying...

"A" =3D "1" # or
"B" =3D "2"

  Is like trying to tell python that it's running on an orange, or that =
it's stored on roadkill.  It just isn't true.  One piece of data, cannot =
be assigned to another piece of data.  That is what variables are for...

A =3D '1' # or
A =3D "1" # or
A =3D 1

  Are all fine.  This stores the string '1' (and in the last case, the =
integer 1) into the variable A.  Now, to pass this onto a class method, =
just include it in the argument list.

class Jim:
  def printarg(self, arg):
    print arg

  As the class definition, then you would write...

guy =3D Jim()
guy.printarg(A)  # calls method printarg and passes the variable A to it =
(called arg in the definition)

  Hope that helped,
  Glen.



  How do you send data from one class to another and can you make one =
string equal another and it still make sense?  Send me in the right =
direction and I can take it from there.

  ex:

  "A" =3D "1"
  "B" =3D "2"

  Thanks for the help.

  Cameron

------=_NextPart_000_00D9_01C0DE12.C00B0860
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 http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; Well, saying...</DIV>
<DIV>&nbsp;</DIV>
<DIV>"A" =3D "1" # or</DIV>
<DIV>"B" =3D "2"</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; Is like trying to tell python that it's running on an =
orange, or=20
that it's stored on roadkill.&nbsp; It just isn't true.&nbsp; One piece =
of data,=20
cannot be assigned to another piece of data.&nbsp; That is what =
variables are=20
for...</DIV>
<DIV>&nbsp;</DIV>
<DIV>A =3D '1' # or</DIV>
<DIV>A =3D "1" # or</DIV>
<DIV>A =3D 1</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; Are all fine.&nbsp; This stores the string '1' (and in the =
last=20
case, the integer 1) into the variable A.&nbsp; Now, to pass this onto a =
class=20
method, just include it in the argument list.</DIV>
<DIV>&nbsp;</DIV>
<DIV>class Jim:</DIV>
<DIV>&nbsp; def printarg(self, arg):</DIV>
<DIV>&nbsp;&nbsp;&nbsp; print arg</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; As the class definition, then you would write...</DIV>
<DIV>&nbsp;</DIV>
<DIV>guy =3D Jim()</DIV>
<DIV>guy.printarg(A)&nbsp; # calls method printarg and passes the =
variable A to=20
it (called arg in the definition)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; Hope that helped,</DIV>
<DIV>&nbsp; Glen.</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV><BR></DIV>
  <DIV><FONT face=3DArial size=3D2>How do you send data from one class =
to another=20
  and can you make one string equal another&nbsp;and it still make =
sense?&nbsp;=20
  Send me in the right direction and I can take it from =
there.</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>ex:</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>"A" =3D "1"</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>"B" =3D "2"</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Thanks for the help.</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial =
size=3D2>Cameron</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_00D9_01C0DE12.C00B0860--