Python Forum

Full Version: What do i have to type in the IDLE shell to use this password manager program?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am doing an assignment in a Python exercise book. I have to create a password manager program that can be used with a command line argument that is the account's name like 'email' or 'blog'. That account's password will be copied to the clipboard so that the user can paste it into a password field. My question is: How do i use this program? What do i have to type in the IDLE shell to show for example the password for 'email'? This is the program i wrote by following the stteps in the book. Any input is much appreciated!

#!
# pw.py - An insecure password locker program.
PASSWORDS={'email':'F97398uifhilh92',
           'blog':'kuhge987De87D',
           'luggage':'12345'}

import sys
if len(sys.argv)<2:
    print('Usage: python pw.py [account] - copy account password')
    sys.exit()

account=sys.argv[1] # first command line arg is the account name

if account in PASSWORDS:
    pyperclip.copy(PASSWORDS[account])
    print('Password for ' + account + ' copied to clipboard.')
else:
    print('There is no account named '+ account)
You don't run programs using IDLE. You run them at your operating system's command line. Line 9 tells you how to run the program.
As ndc85430 says, you run this from the command line as documented in line 9 of the code. Note that line 9 assumes you run Python programs using "python" and your program is in the current folder and is named "pw.py". Your situation may differ. If you use "python3" to run python programs and your program is in a subfolder of the current directory named "exercises" you might need to type "python3 exercises/pw.py email".
Thanks for the info. It works.