[Tutor] What's wrong with this code?

Liam Clarke cyresse at gmail.com
Thu Jul 7 12:15:09 CEST 2005

And please, please, post the whole error message, as it specifies where the 
error occurred.

Oh, yes, and I think I answered this - 

I meant to ask why the main part after the password is not working right.
No one has answered that yet. When I run the code and try to load a file
that has been saved, a TypeError appears.

Try id[site] and passcard[site] not id(site) and passcard(site). It'll make 
a world of difference, honest.

On 7/7/05, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
> Hi Nathan,
> Other folks are pointing out why you're getting certain error messages.
> You may also want to consider breaking up the long second-half of the
> program into into its own set of functions. I believe that the second
> half could look something like this:
> ######
> while menu_choice != 9:
> menu_choice = input("Choose an option:")
> if menu_choice == 1:
> add_login_command()
> elif menu_choice == 2:
> lookup_login_command()
> elif menu_choice == 3:
> remove_login_command()
> elif menu_choice == 4:
> display_login_command()
> elif menu_choice == 5:
> save_login_command()
> elif menu_choice == 6:
> load_login_command()
> ######
> The idea behind the break-up here is to make it a little easier to see, at
> a high level, how the program works. As a side benefit, it should help to
> avoid wacky things like certain menu choices munging up the variables used
> by other menu choices.
> Finally, by physcially shortening that loop, it's easier to see that we'll
> always ask for a menu_choice whenever we hit the start of the loop. In
> contrast, the original code is so long that we may have forgotten, which
> is why each menu command appears to repeat the "Choose an option:"
> question.
> (When you learn a little more about Python, we can talk about the concept
> of "dispatch tables" to further dissolve that code, but let's talk about
> that later.)
> I guess I'm trying to say: style can mattes because it can help you fix
> your program's bugs faster. *grin*
> Best of wishes to you!
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

'There is only one basic human right, and that is to do as you damn well 
And with it comes the only basic human duty, to take the consequences.'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050707/f23b2f4c/attachment.htm

More information about the Tutor mailing list