[Tutor] basic universe simulating for dummies

sheri din22@home.com
Sun, 19 Nov 2000 11:20:18 -0600


This is a multi-part message in MIME format.

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

hello everybody! i am a newbie programmer wannabe and i am trying to =
learn to=20
program in python by studying joe strout's basic universe simulator. its =
the only
code i've ever seen that does something non-trivial and interesting that =
i think i=20
could actually understand how it works. i have been rewriting it and i'm =
at the
point where i can type look and see whats in a room. next step is to =
move from
one room to another. anyway i have been looking at this code for a while =
and i'm
still mystified by


# declare some constants
the =3D 1
a =3D 2
The =3D 101
A =3D 102

# get name
 def GetName(self, article=3D0):
  if not article: return self.name
  if article=3D=3Dthe:
   if hasattr(self,'the'): return self.the + ' ' + self.name
   return 'the ' + self.name
  if article=3D=3Da:
   if hasattr(self,'a'): return self.a + ' ' + self.name
   return 'a ' + self.name=20
  if article=3D=3DThe:
   if hasattr(self,'the'): return cap(self.the) + ' ' + self.name
   return 'The ' + self.name
  if article=3D=3DA:
   if hasattr(self,'A'): return cap(self.a) + ' ' + self.name
   return 'A ' + self.name=20
   return self.name


why assign different numbers? what does this code do?
for me this is the most opaque part of the program except
for the parser which i'm treating like a black box for now.
anyway sorry i tend to ramble but if someone could comment
on this code i would really appreciate it.=20

------=_NextPart_000_0007_01C0521A.B26EB140
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>hello everybody! i am a newbie =
programmer wannabe=20
and i am trying to learn to </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>program in python by studying joe =
strout's basic=20
universe simulator. its the only</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>code i've ever seen that does something =
non-trivial=20
and</FONT><FONT face=3DArial size=3D2> interesting that i think i =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>could actually</FONT><FONT face=3DArial =
size=3D2>=20
understand how it works. i have been rewriting it and i'm at =
the</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>point where i can type look and see =
whats in a=20
room. next step is to move from</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>one room to another. anyway i have been =
looking at=20
this code for a while and i'm</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>still mystified by</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><BR># declare some constants<BR>the =3D =
1<BR>a =3D=20
2<BR>The =3D 101<BR>A =3D 102</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2># get name<BR>&nbsp;def GetName(self,=20
article=3D0):<BR>&nbsp;&nbsp;if not article: return =
self.name<BR>&nbsp;&nbsp;if=20
article=3D=3Dthe:<BR>&nbsp;&nbsp;&nbsp;if hasattr(self,'the'): return =
self.the + ' '=20
+ self.name<BR>&nbsp;&nbsp;&nbsp;return 'the ' + =
self.name<BR>&nbsp;&nbsp;if=20
article=3D=3Da:<BR>&nbsp;&nbsp;&nbsp;if hasattr(self,'a'): return self.a =
+ ' ' +=20
self.name<BR>&nbsp;&nbsp;&nbsp;return 'a ' + =
self.name&nbsp;<BR>&nbsp;&nbsp;if=20
article=3D=3DThe:<BR>&nbsp;&nbsp;&nbsp;if hasattr(self,'the'): return =
cap(self.the)=20
+ ' ' + self.name<BR>&nbsp;&nbsp;&nbsp;return 'The ' +=20
self.name<BR>&nbsp;&nbsp;if article=3D=3DA:<BR>&nbsp;&nbsp;&nbsp;if=20
hasattr(self,'A'): return cap(self.a) + ' ' +=20
self.name<BR>&nbsp;&nbsp;&nbsp;return 'A ' +=20
self.name&nbsp;<BR>&nbsp;&nbsp;&nbsp;return self.name</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>why assign different numbers? what does =
this code=20
do?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>for me this is the most opaque part of =
the program=20
except</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>for the parser which i'm treating like =
a black box=20
for now.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>anyway sorry i tend to ramble but if =
someone could=20
comment</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>on this code i would really appreciate =
it.=20
</FONT></DIV></BODY></HTML>

------=_NextPart_000_0007_01C0521A.B26EB140--