6.2 Using input() and getpass() for user input
Some Python scripts depend on gathering input from a user. There are several ways to do this. One popular technique is to use the console to prompt a user for input interactively.
There are two relatively common situations:
Ordinary input: This will provide a helpful echo of the characters being entered.
Secure, no echo input: This is often used for passwords. The characters entered aren’t displayed, providing a degree of privacy. We use the getpass() function in the getpass module for this.
As an alternative to interactive input, we’ll look at some other approaches in the Using argparse to get command-line input recipe later in this chapter.
The input() and getpass() functions are just two implementation choices to read from the console. It turns out that getting the string of characters is only the first step in gathering useful data. The input also needs to...