0

So I wrote a script, and it actually worked for a while. I import the getpass module, and sure enough the user name was echoed, but the password was not. I ran the script several weeks later, and now the password is echoing. Here's my code:

import getpass

def get_login():
    """get un/pw cerdentials for server"""
    username = input("Username: ")
    password = getpass.getpass()

    return username, password

def some_other_function():
    (username, password) = get_login()

When I run the script i get a message "Warning: Password input may be echoed." and sure enough, it's echoed.

I have tried slightly different things such as defining the promt and stream (prompt='Password: ', stream=None)

Thanks

MS-87
  • 173
  • 1
  • 10
  • 3
    `getpass.getpass` _attempts_ to turn echo off on your terminal. If it can't do that, it issues a warning. See [`getpass`](https://docs.python.org/3/library/getpass.html) – khelwood Oct 23 '18 at 15:03
  • 2
    So where are you running the script? In the console of your IDE perhaps? – Martijn Pieters Oct 23 '18 at 15:04
  • I am using VScode. I tried it on pythons IDLE and it worked fine... Thanks for pointing me in the right direction. Something must have changed in my visual studio code setup. – MS-87 Oct 23 '18 at 15:15

0 Answers0