<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Awesome, awesome, awesome.&nbsp; I will check my script when I get home from work, but your&nbsp;explanation is top notch!&nbsp; I think I understand it now.&nbsp; Thank you.</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">I will post my corrected script and the answers when I get home from work tonight.</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">&nbsp;</DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Many thanks!<BR><BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">----- Original Message ----<BR>From: Evert Rol &lt;evert.rol@gmail.com&gt;<BR>To: Bryan Magalski &lt;bryan_magalski@yahoo.com&gt;<BR>Cc: tutor@python.org<BR>Sent: Thursday, November 15, 2007 11:37:43 AM<BR>Subject: Re: [Tutor] Interactive Menu Woes<BR><BR>&gt; Thank you for your suggestion.&nbsp; I did not create the original&nbsp; <BR>&gt; script, so it will stay as is and my addition for the menu has been&nbsp; <BR>&gt; adjusted.<BR>&gt;<BR>&gt; Now that I can make a clear distinction of what I am returning, I&nbsp; <BR>&gt; am getting a new error that leads me that I am trying to call a&nbsp; <BR>&gt; function that cannot be seen when instantiated:<BR>&gt;<BR>&gt; To add a name, please input he following information:<BR>&gt; Name: Bryan<BR>&gt; Number: 1234567890<BR>&gt; What type of number is this? (choose one):<BR>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; 1. Home:<BR>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2. Work:<BR>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3. Cell:<BR>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : 1<BR>&gt; Traceback (most recent call last):<BR>&gt;&nbsp; File "<A href="http://menu_modified.py/" target=_blank>menu_modified.py</A>", line 95, in &lt;module&gt;<BR>&gt;&nbsp; &nbsp; menu.addName()<BR>&gt;&nbsp; File "<A href="http://menu_modified.py/" target=_blank>menu_modified.py</A>", line 73, in addName<BR>&gt;&nbsp; &nbsp; enter(name, number, returnType)<BR>&gt; AttributeError: phoneentry instance has no __call__ method<BR><BR><BR>You're first creating a phoneentry object, and then calling the&nbsp; <BR>actual object. That doesn't work; it's somewhat similar to:<BR>&gt;&gt;&gt; a = dict()<BR>&gt;&gt;&gt; a(key=5)<BR>which gives a slightly
 different error, but obviously the correct&nbsp; <BR>form is:<BR>&gt;&gt;&gt; a = dict(key=5)<BR>and also<BR>&gt;&gt;&gt; phoneentry(name, number, returnType)<BR><BR>When creating an object (instantiating the class), the __init__&nbsp; <BR>method is automatically called, and you provide the arguments of the&nbsp; <BR>__init__ method when creating the object.<BR>In your current script, the actual entry you create (enter =&nbsp; <BR>phoneenetry()) creates an entry with name &amp; number 'Unknown' (default&nbsp; <BR>arguments), and types=UNKNOWN; then you want to assign the actual&nbsp; <BR>values to the entry. If you *really* want to do this (don't, though),&nbsp; <BR>you'd be doing:<BR>entry = phoneentry()<BR><A href="http://entry.name/" target=_blank>entry.name</A> = name<BR>entry.number = number<BR>entry.types = returnType<BR><BR>See the add() method in the phonedb class, where it is done correctly.<BR><BR><BR>A few other thoughts:<BR>- what does
 numberType return if 'n is not in typeDict'? It should&nbsp; <BR>return UNKNOWN I guess.<BR>- why not remove that function, and put typeDict to addName? It's&nbsp; <BR>really only one extra line, and avoids the whole extra function call&nbsp; <BR>(replacing it with something one might call a 'dictionary call')<BR>- I noticed you use tabs, while the original part of the code uses&nbsp; <BR>spaces. Try to avoid mixing them: at some point things will go wrong&nbsp; <BR>(spaces are preferred; for a good read on that and other stuff:&nbsp; <BR><A href="http://www.python.org/doc/essays/styleguide.html" target=_blank>http://www.python.org/doc/essays/styleguide.html</A> )<BR><BR><BR>&nbsp; Evert<BR><BR></DIV>
<DIV style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><BR></DIV></div><br>

      <hr size=1>Never miss a thing.  <a href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs"> Make Yahoo your homepage.</a>

</body></html>