Is it possible to hide the message that gets displayed if getpass() cannot hide the message?
GetPassWarning: Can not control echo on the terminal.
Warning: Password input may be echoed.
Is it possible to replace this message with something else more user friendly? If it is, how?
As far as I know, this message isn't intended to be customizable. Here's a workaround.
Behind the scenes,
getpass.getpassis the following function when echo can't be disabled.If you want to customize the message, you could just write your own function that calls
getpass._raw_input. For example,You can then call your
custom_getpassfunction directly, or you can replacegetpass.getpasswith your custom function.Note that the approach above will always print the custom warning and will always echo the password to the user. If you only want to use the custom function when the fallback
getpassis being used, you could do that by simply checking which functiongetpassis using forgetpass.getpass. For exampleBeware this could break without notice in future versions of Python since the workaround relies on the module's "private" functions.