[Tutor] Help with file I/O.

Nathan Pinno falcon3166 at hotmail.com
Thu Aug 4 03:27:44 CEST 2005


It does indeed echo. I forgot to add that.
----- Original Message ----- 
From: "Nathan Pinno" <falcon3166 at hotmail.com>
To: "Alan G" <alan.gauld at freenet.co.uk>; "Alberto Troiano" 
<albertito_g at hotmail.com>; "Danny Yoo" <dyoo at hkn.eecs.berkeley.edu>; "luke" 
<rabidpoobear at gmail.com>
Cc: <tutor at python.org>
Sent: Wednesday, August 03, 2005 3:42 PM
Subject: Re: [Tutor] Help with file I/O.


> The error was:
> Warning: Problem with getpass. Passwords may be echoed.
>
>
>
> My code is:
>
> #This is for a password protected program to store passwords.
> import getpass
> password = "hello"
> sitelist = {}
>
> def main_menu():
>    print "1) Add a login info card"
>    print "2) Lookup a login info card"
>    print "3) Remove a login info card"
>    print "4) Print Login info list"
>    print "9) Exit"
>
> def add_site():
>    print "Add a login info card"
>    site = raw_input("Site: ")
>    id = raw_input("User ID: ")
>    passcard = getpass.getpass("Password: ")
>    sitelist[site] = [id,passcard]
>
> def lookup_site():
>    print "Lookup a login info card"
>    site = raw_input("Site: ")
>    if sitelist.has_key(site):
>        print "The ID is: ",sitlist[site][0]
>        print "The password is: ",sitelist[site][1]
>    else:
>        print site," was not found."
>
> def remove_site():
>     print "Remove a login info card"
>     site = raw_input("Site: ")
>     if sitelist.has_key(site):
>         del sitelist[site]
>     else:
>         print site," was not found."
>
> def print_login_info():
>    print "Login Info"
>    for x in sitelist.keys():
>        print "Site: ",x," \tID: ",sitelist[x][0]," \tPassword:
> ",sitelist[x][1],"\n"
>
> print "The Password Program"
> print "By Nathan Pinno"
> print
> answer = getpass.getpass("What is the password? ")
> while password != answer:
>    print "The password is incorrect."
>    answer = getpass.getpass("What is the password? ")
>
> print "Welcome to the second half of the program."
> while 1:
>    main_menu()
>    menu_choice = int(raw_input("Choose an option: "))
>    if menu_choice == 1:
>        add_site()
>    elif menu_choice == 2:
>        lookup_site()
>    elif menu_choice == 3:
>        remove_site()
>    elif menu_choice == 4:
>        print_login_info()
>    elif menu_choice == 9:
>        break
>    else:
>        print "That's not an option!"
> print "Have a nice day!"
>
>
>
> Thanks for the help!
>
> Nathan Pinno
>
> ----- Original Message ----- 
> From: "Alan G" <alan.gauld at freenet.co.uk>
> To: "Nathan Pinno" <falcon3166 at hotmail.com>; "Alberto Troiano"
> <albertito_g at hotmail.com>; "Danny Yoo" <dyoo at hkn.eecs.berkeley.edu>; 
> "luke"
> <rabidpoobear at gmail.com>
> Cc: <tutor at python.org>
> Sent: Wednesday, August 03, 2005 3:36 PM
> Subject: Re: [Tutor] Help with file I/O.
>
>
>>
>>> When I ran my new password program, using getpass, it warned me that
>>> passwords might be echoed, because there was a problem with getpass. How
>>> do I fix this?
>>
>> Can we see the code and error message. Otherwise we'd just be guessing...
>>
>> The Python error messages usually tell you as much as you need to fix
>> it, like roughly where to look and what the nature of problem is.
>>
>> If its not really an error what happens when you run your program?
>> Does getpass import? (Try it at the >>> prompt)
>>
>> If so does it in fact echo?
>>
>> Alan G.
>>
>>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


More information about the Tutor mailing list