[Tutor] getpass

Steven D'Aprano steve at pearwood.info
Sat Jun 16 08:21:02 CEST 2012


Mike Nickey wrote:
> Hey all,
> 
> I'm working on a bit of code here and I'm having an issue with
> getpass. In the documentation, it says it hides the text entered
> 
> "Prompt the user for a password without echoing." --
> http://www.python.org/doc//current/library/getpass.html
> 
> However when I run it in Eclipse, the password is clear as day.

Then don't run it in Eclipse. Seriously.

Hiding the user's input requires getpass to work hand-in-hand with the 
terminal. If another piece of software, like Eclipse, gets in the way, or if 
the terminal is not one which is supported, then getpass falls back on 
whatever it can, which unfortunately displays the password.

Idle also fails to work properly with getpass. If you run getpass in Idle for 
Python 2.7, the prompt is written back to the parent terminal, not the Idle 
window, where the user may not see it.

In general, code which requires intimate knowledge of the terminal should be 
run directly from a terminal and not via an intermediate layer like Eclipse or 
Idle.



-- 
Steven



More information about the Tutor mailing list