use getpass in visual studio code
Question:
I am using this code:
import getpass
pwd = getpass.getpass(prompt = 'Please enter password:')
Unfortunatley I cannot enter anything in the terminal. Am I missing something?
Answers:
The principle of this function is that you can enter text as in a classic input but it is not displayed on the screen.
If you try to add print(pwd)
and hit some keys at the time of input, it should return exactly what you typed
I was trying to figure this out myself, and realised that in VS Code the prompt to enter the password appears at the top of the window, not inline as it does in Jupyter.
I found this a bit confusing coming from a Jupyter environment, so added some code to check if the user was running VS Code and display an additional message:
if any(['VSCODE' in x for x in os.environ.keys()]):
print('Please enter password in the prompt above')
I am using this code:
import getpass
pwd = getpass.getpass(prompt = 'Please enter password:')
Unfortunatley I cannot enter anything in the terminal. Am I missing something?
The principle of this function is that you can enter text as in a classic input but it is not displayed on the screen.
If you try to add print(pwd)
and hit some keys at the time of input, it should return exactly what you typed
I was trying to figure this out myself, and realised that in VS Code the prompt to enter the password appears at the top of the window, not inline as it does in Jupyter.
I found this a bit confusing coming from a Jupyter environment, so added some code to check if the user was running VS Code and display an additional message:
if any(['VSCODE' in x for x in os.environ.keys()]):
print('Please enter password in the prompt above')