Python: how to conceal input

Question:

How do you conceal the input of raw_input? For example, I want:

password = raw_input("Password: ")

To be

Password: ********
#or
Password: #hide the characters (i.e. no echo)

Instead of displaying the string. How can I do so?

Asked By: Eugene

||

Answers:

Use getpass:

import getpass

password = getpass.getpass('Password: ')
Answered By: Nicolas
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.