Cray Kao
Cray Kao

Reputation: 573

Is there easy way to prevent echo from input?

How to prevent echo from input ??

Have tried "getpass()" but no luck.

On Windows IDLE, it doesn't work

    Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import getpass
>>> p = getpass.getpass(prompt="Input: ")
Warning: Password input may be echoed.
Input: abc <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< It still echos..

On the terminal of the Windows, it works

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import getpass
>>> p = getpass.getpass(prompt="Input: ")
Input:
>>>

Is there a easy way to prevent echo from input ?

Upvotes: 2

Views: 11765

Answers (1)

llb
llb

Reputation: 1741

I'm assuming your first example there is in IDLE.

From getpass.win_getpass():

if sys.stdin is not sys.__stdin__:
    return fallback_getpass(prompt, stream)

IDLE replaces sys.stdin with a different object. getpass detects that somebody has wrapped stdin and fails for security reasons.

See: http://bugs.python.org/issue9290

Upvotes: 3

Related Questions