3

I am looking for an example of an instance where we import the Python getpass library, enter our password, and the password does not echo to the terminal.

Here is an example where it does echo the password to the terminal:

$ python
>>> import getpass
>>> getpass.GetPassWarning
<class 'getpass.GetPassWarning'>
>>> getpass.getpass(stream=None)
Password:
'hello'
>>> 

Can someone give an example where it does not echo to the terminal?

Thanks!

1
  • 5
    You have to assign the value : my_pwd = getpass.getpass(stream=None) Commented Apr 18, 2014 at 18:42

1 Answer 1

7

You should write or save the password to a variable. Then the password will not be echoed. for example:

import getpass                                                                       

p=getpass.getpass("Enter the Password:")

Enter the Password:

print (p)

Output on console: pass@123

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.