why does getpass() show the input?
Robin Haswell
rob at digital-crocus.com
Thu Aug 10 05:24:21 EDT 2006
rob at aranea:~$ python
Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> # The cause of this problem is because you're using the console
... # to test getpass. getpass.getpass()'s return value is the
... # password inputted, but because you're not capturing its return
... # value, the console is printing it. Let me demonstrate:
...
>>> import getpass
>>> getpass.getpass()
Password:
'This is a password'
>>> # The password is printed, however, if I capture the output:
...
>>> mypass = getpass.getpass()
Password:
>>> # The password is not shown, and is stored in mypass:
...
>>> print mypass
This is a password
>>>
>>> # Thank you, and goodnight.
... #
... # -Rob
...
>>>
On Wed, 09 Aug 2006 20:42:18 +0000, John Salerno wrote:
> I'm guessing this might have something to do with my particular system?
>
> >>> getpass.getpass()
> Warning: Problem with getpass. Passwords may be echoed.
> Password: hello
> 'hello'
More information about the Python-list
mailing list