Re: Password prompting

Guido.van.Rossum@cwi.nl
Tue, 28 Mar 1995 16:56:50 +0200

> How do I prompt for a password in Python? i.e. with no feedback of the
> typed in characters. This is for TTY terminal input on which I normally use
> raw_input() for standard prompts.

You could use fcntl.ioctl() or the termios module (undocumented), or
you could do

os.system("stty -echo")
passwd = raw_input()
os.system("stty echo")

I don't know of non-UNIX solutions.

--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>