PyInputPlus¶
PyInputPlus is a Python 3 and 2 module to provide input()
- and raw_input()
-like functions with additional validation features. PyInputPlus was created and is maintained by Al Sweigart.
Installation¶
PyInputPlus can be installed from PyPI using pip:
pip install pyinputplus
On macOS and Linux, installing PyInputPlus for Python 3 is done with pip3:
pip3 install pyinputplus
If you run into permissions errors, try installing with the –user option:
pip install --user pyinputplus
The PySimpleValidate and stdiomask modules will also be installed as a part of PyInputPlus’s installation.
Quickstart¶
PyInputPlus will keep asking the user for text until they enter valid input. It’s recommended to import PyInputPlus with the shorter name pyip
.
>>> import pyinputplus as pyip
All of PyInputPlus’s functions begin with the input
, such as inputStr()
or inputDate()
. Collectively, they are referred to in this documentation as the input*()
functions.
For example, you can ask the user for an integer with inputInt()
, and the return value will be an integer instead of the string that input()
would normally return:
>>> input()
42
'42'
>>> response = pyip.inputInt() # keep asking until an int is entered
forty two
'forty two' is not an integer.
42
>>> response
42
You could specify a prompt, along with any restrictions you’d like to impose:
>>> response = pyip.inputInt('Enter your age: ', min=1)
Enter your age: 0
Number must be at minimum 1.
Enter your age: 2
>>> response
2
There are several functions for different common types of data:
>>> response = pyip.inputEmail()
alinventwithpython.com
'alinventwithpython.com' is not a valid email address.
al@inventwithpython.com
>>> response
'al@inventwithpython.com'
You could also present a small menu of options to the user:
>>> response = pyip.inputMenu(['cat', 'dog', 'moose'])
Please select one of the following:
* cat
* dog
* moose
cat
>>> response
'cat'
>>> response = pyip.inputMenu(['cat', 'dog', 'moose'], numbered=True)
Please select one of the following:
1. cat
2. dog
3. moose
1
>>> response
'cat'
See the list of functions to get an idea of the kinds of information you can get from the user.
Common input*() Parameters¶
The following parameters are available for all of the input*()
functions. You can see this documentation by calling help(pyip.parameters)
:
>>> import pyinputplus as pyip
>>> help(pyip.parameters)
Help on function parameters in module pyinputplus:
parameters()
Common parameters for all ``input*()`` functions in PyInputPlus:
* ``prompt`` (str): The text to display before each prompt for user input. Identical to the prompt argument for Python's ``raw_input()`` and ``input()`` functions.
* ``default`` (str, None): A default value to use should the user time out or exceed the number of tries to enter valid input.
* ``blank`` (bool): If ``True``, a blank string will be accepted. Defaults to ``False``.
* ``timeout`` (int, float): The number of seconds since the first prompt for input after which a ``TimeoutException`` is raised the next time the user enters input.
* ``limit`` (int): The number of tries the user has to enter valid input before the default value is returned.
* ``strip`` (bool, str, None): If ``None``, whitespace is stripped from value. If a str, the characters in it are stripped from value. If ``False``, nothing is stripped.
* ``allowlistRegexes`` (Sequence, None): A sequence of regex str that will explicitly pass validation.
* ``blocklistRegexes`` (Sequence, None): A sequence of regex str or ``(regex_str, error_msg_str)`` tuples that, if matched, will explicitly fail validation.
* ``applyFunc`` (Callable, None): An optional function that is passed the user's input, and returns the new value to use as the input.
* ``postValidateApplyFunc`` (Callable, None): An optional function that is passed the user's input after it has passed validation, and returns a transformed version for the ``input*()`` function to return.
API Reference¶
PyInputPlus by Al Sweigart al@inventwithpython.com
A Python 2 and 3 module to provide input()- and raw_input()-like functions with additional validation features.
-
exception
pyinputplus.
PyInputPlusException
¶ Base class for exceptions raised when PyInputPlus functions encounter a problem. If PyInputPlus raises an exception that isn’t this class, that indicates a bug in the module.
-
exception
pyinputplus.
ValidationException
¶ This exception is raised when a
validate*()
function is called and the input fails validation. For example,validateInt('four')
will raise this. This exception class is for all the PySimpleValidate wrapper functions (validateStr()
, etc.) that PyInputPlus provides so thatpyinputplus.ValidationException
is raised instead ofpysimplevalidate.ValidationException
.
-
exception
pyinputplus.
TimeoutException
¶ This exception is raised when the user has failed to enter valid input before the timeout period.
-
exception
pyinputplus.
RetryLimitException
¶ This exception is raised when the user has failed to enter valid input within the limited number of tries given.
-
pyinputplus.
parameters
()¶ Common parameters for all
input*()
functions in PyInputPlus:prompt
(str): The text to display before each prompt for user input. Identical to the prompt argument for Python’sraw_input()
andinput()
functions.default
(str, None): A default value to use should the user time out or exceed the number of tries to enter valid input.blank
(bool): IfTrue
, a blank string will be accepted. Defaults toFalse
.timeout
(int, float): The number of seconds since the first prompt for input after which aTimeoutException
is raised the next time the user enters input.limit
(int): The number of tries the user has to enter valid input before the default value is returned.strip
(bool, str, None): IfNone
, whitespace is stripped from value. If a str, the characters in it are stripped from value. IfFalse
, nothing is stripped.allowlistRegexes
(Sequence, None): A sequence of regex str that will explicitly pass validation.blocklistRegexes
(Sequence, None): A sequence of regex str or(regex_str, error_msg_str)
tuples that, if matched, will explicitly fail validation.applyFunc
(Callable, None): An optional function that is passed the user’s input, and returns the new value to use as the input.postValidateApplyFunc
(Callable, None): An optional function that is passed the user’s input after it has passed validation, and returns a transformed version for theinput*()
function to return.
-
pyinputplus.
inputStr
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter any string input. This is similar to Python’s
input()
andraw_input()
functions, but with PyInputPlus’s additional features such as timeouts, retry limits, stripping, allowlist/blocklist, etc.Validation can be performed by the validationFunc argument, which raises an exception if the input is invalid. The exception message is used to tell the user why the input is invalid.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> result = inputStr('Enter name> ') Enter name> Al >>> result 'Al'
-
pyinputplus.
inputCustom
(customValidationFunc, prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter input. This is similar to Python’s
input()
andraw_input()
functions, but with PyInputPlus’s additional features such as timeouts, retry limits, stripping, allowlist/blocklist, etc.Validation can be performed by the
customValidationFunc
argument, which raises an exception if the input is invalid. The exception message is used to tell the user why the input is invalid.Run
help(pyinputplus.parameters)
for an explanation of the common parameters.customValidationFunc
(Callable): A function that is used to validate the input. Validation fails if it raises an exception, and the exception message is displayed to the user.
>>> def raiseIfUppercase(text): ... if text.isupper(): ... raise Exception('Input cannot be uppercase.') ... >>> inputCustom(raiseIfUppercase) HELLO Input cannot be uppercase. Hello 'Hello'
-
pyinputplus.
inputNum
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None, min=None, max=None, greaterThan=None, lessThan=None)¶ Prompts the user to enter a number, either an integer or a floating-point value. Returns an int or float value (depending on if the user entered a decimal in their input.)
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.min
(None, float): If notNone
, the minimum accepted numeric value, including the minimum argument.max
(None, float): If notNone
, the maximum accepted numeric value, including the maximum argument.greaterThan
(None, float): If notNone
, the minimum accepted numeric value, not including thegreaterThan
argument.lessThan
(None, float): If notNone
, the maximum accepted numeric value, not including thelessThan
argument.
>>> import pyinputplus as pyip >>> response = pyip.inputNum() forty two 'forty two' is not a number. 42 >>> response 42 >>> response = pyip.inputNum() 9 >>> type(response) <class 'int'> >>> response = pyip.inputNum() 9.0 >>> type(response) <class 'float'> >>> response = pyip.inputNum(min=4) 3 Number must be at minimum 4. 4 >>> response 4 >>> response = pyip.inputNum(greaterThan=4) 4 Number must be greater than 4. 4.1 >>> response 4.1 >>> response = pyip.inputNum(limit=2) dog 'dog' is not a number. cat 'cat' is not a number. Traceback (most recent call last): ... pyinputplus.RetryLimitException
-
pyinputplus.
inputInt
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None, min=None, max=None, lessThan=None, greaterThan=None)¶ Prompts the user to enter an integer value. Returns the integer as an int value.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.min
(None, float): If notNone
, the minimum accepted numeric value, including the minimum argument.max
(None, float): If notNone
, the maximum accepted numeric value, including the maximum argument.greaterThan
(None, float): If notNone
, the minimum accepted numeric value, not including thegreaterThan
argument.lessThan
(None, float): If notNone
, the maximum accepted numeric value, not including thelessThan
argument.
>>> import pyinputplus as pyip >>> response = pyip.inputInt() 42 >>> response 42 >>> type(response) <class 'int'> >>> response = pyip.inputInt(min=4) 4 >>> response 4 >>> response = pyip.inputInt(min=4) 3 Number must be at minimum 4. -5 Number must be at minimum 4. 5 >>> response 5 >>> response = pyip.inputInt(blockRegexes=[r'[13579]$']) 43 This response is invalid. 41 This response is invalid. 42 >>> response 42 >>> response = pyip.inputInt() 42.0 >>> response 42 >>> type(response) <class 'int'>
-
pyinputplus.
inputFloat
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None, min=None, max=None, lessThan=None, greaterThan=None)¶ Prompts the user to enter a floating point number value. Returns the number as a float.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.min
(None, float): If notNone
, the minimum accepted numeric value, including the minimum argument.max
(None, float): If notNone
, the maximum accepted numeric value, including the maximum argument.greaterThan
(None, float): If notNone
, the minimum accepted numeric value, not including thegreaterThan
argument.lessThan
(None, float): If notNone
, the maximum accepted numeric value, not including thelessThan
argument.
>>> import pyinputplus as pyip >>> response = pyip.inputFloat() 42 >>> response 42.0 >>> type(response) <class 'float'>
-
pyinputplus.
inputChoice
(choices, prompt='_default', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None, caseSensitive=False)¶ Prompts the user to enter one of the provided choices. Returns the selected choice as a string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.choices
(Sequence): A sequence of strings, one of which the user must enter.aseSensitive
(bool): IfTrue
, the user must enter a choice that matches the case of the string in choices. Defaults to False.
>>> import pyinputplus as pyip >>> response = pyip.inputChoice(['dog', 'cat']) Please select one of: dog, cat dog >>> response 'dog' >>> response = pyip.inputChoice(['dog', 'cat']) Please select one of: dog, cat CAT >>> response 'cat' >>> response = pyip.inputChoice(['dog', 'cat']) Please select one of: dog, cat mouse 'mouse' is not a valid choice. Please select one of: dog, cat Dog >>> response 'dog'
-
pyinputplus.
inputMenu
(choices, prompt='_default', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None, numbered=False, lettered=False, caseSensitive=False)¶ Prompts the user to enter one of the provided choices. Also displays a small menu with bulleted, numbered, or lettered options. Returns the selected choice as a string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputMenu(['dog', 'cat']) Please select one of the following: * dog * cat DOG >>> response 'dog' >>> response = pyip.inputMenu(['dog', 'cat'], numbered=True) Please select one of the following: 1. dog 2. cat 2 >>> response 'cat' >>> response = pyip.inputMenu(['dog', 'cat'], lettered=True) Please select one of the following: A. dog B. cat B >>> response 'cat' >>> response = pyip.inputMenu(['dog', 'cat'], lettered=True) Please select one of the following: A. dog B. cat dog >>> response 'dog' >>> import pyinputplus as pyip >>> response = pyip.inputMenu(['dog', 'cat'], caseSensitive=True) Please select one of the following: * dog * cat Dog 'Dog' is not a valid choice. Please select one of the following: * dog * cat dog >>> response 'dog'
-
pyinputplus.
inputDate
(prompt='', formats=None, default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a date, formatted as a strptime-format in the formats list. Returns a datetime.date object.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputDate() 2019/10/31 >>> response datetime.date(2019, 10, 31) >>> response = pyip.inputDate() Oct 2019 'Oct 2019' is not a valid date. 10/31/2019 >>> response datetime.date(2019, 10, 31) >>> response = pyip.inputDate(formats=['%b %Y']) Oct 2019 >>> response datetime.date(2019, 10, 1)
-
pyinputplus.
inputDatetime
(prompt='', formats=('%m/%d/%Y %H:%M:%S', '%m/%d/%y %H:%M:%S', '%Y/%m/%d %H:%M:%S', '%y/%m/%d %H:%M:%S', '%x %H:%M:%S', '%m/%d/%Y %H:%M', '%m/%d/%y %H:%M', '%Y/%m/%d %H:%M', '%y/%m/%d %H:%M', '%x %H:%M', '%m/%d/%Y %H:%M:%S', '%m/%d/%y %H:%M:%S', '%Y/%m/%d %H:%M:%S', '%y/%m/%d %H:%M:%S', '%x %H:%M:%S'), default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a datetime, formatted as a strptime-format in the formats list. Returns a
datetime.datetime
object.Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputDatetime() 2019/10/31 12:00:01 >>> response datetime.datetime(2019, 10, 31, 12, 0, 1) >>> response = pyip.inputDatetime(formats=['hour %H minute %M']) hour 12 minute 1 >>> response datetime.datetime(1900, 1, 1, 12, 1)
-
pyinputplus.
inputTime
(prompt='', formats=('%H:%M:%S', '%H:%M', '%X'), default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a date, formatted as a strptime-format in the formats list. Returns a
datetime.time
object.Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputTime() 12:00:01 >>> response datetime.time(12, 0, 1) >>> response = pyip.inputTime() 12:00 >>> response datetime.time(12, 0) >>> response = pyip.inputTime(formats=['hour %H minute %M']) hour 12 minute 1 >>> response datetime.time(12, 1)
-
pyinputplus.
inputUSState
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None, returnStateName=False)¶ Prompts the user to enter United States state name or abbreviation. Returns the state abbreviation (unless
returnStateName
isTrue
, in which case the full state name in titlecase is returned.)Run
help(pyinputplus.parameters)
for an explanation of the common parameters.returnStateName
(bool): IfTrue
, the full state name is returned, i.e.'California'
. Otherwise, the abbreviation, i.e.'CA'
. Defaults toFalse
.
>>> import pyinputplus as pyip >>> response = pyip.inputUSState() ca >>> response 'CA' >>> response = pyip.inputUSState() California >>> response 'CA' >>> response = pyip.inputUSState(returnStateName=True) ca >>> response 'California'
-
pyinputplus.
inputMonth
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a month name. Returns a string of the selected month name in titlecase.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputMonth() 3 >>> response 'March' >>> response = pyip.inputMonth() Mar >>> response 'March' >>> response = pyip.inputMonth() MARCH >>> response 'March'
-
pyinputplus.
inputDayOfWeek
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user for a day of the week. Returns the day name in titlecase.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputDayOfWeek() mon >>> response 'Monday' >>> response = pyip.inputDayOfWeek() FRIDAY >>> response 'Friday'
-
pyinputplus.
inputDayOfMonth
(year, month, prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a numeric month from 1 to 28, 30, or 31 (or 29 for leap years), depending on the given month and year. Returns the entered day as an integer.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.year
(int): The given year, which determines the range of days in the month.month
(int): The given month, which determines the range of days that can be selected.
>>> import pyinputplus as pyip >>> response = pyip.inputDayOfMonth(2019, 10) 31 >>> response 31 >>> response = pyip.inputDayOfMonth(2000, 2) 29 >>> response 29 >>> response = pyip.inputDayOfMonth(2001, 2) 29 '29' is not a day in the month of February 2001 1 >>> response 1
-
pyinputplus.
inputIP
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompt the user to enter an IPv4 or IPv6 address. Returns the entered IP address as a string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.
-
pyinputplus.
inputRegex
(regex, flags=0, prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompt the user to enter a string that matches the provided regex string (or regex object) and flags. Returns the entered string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.
-
pyinputplus.
inputRegexStr
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompt the user to enter a regular expression string. (Only Python-style regex strings are accepted, not Perl- or JavaScript-style.) Returns the entered regular expression string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.
-
pyinputplus.
inputURL
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a URL. Returns the URL as a string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputURL() hello world 'hello world' is not a valid URL. https://google.com >>> response 'https://google.com' >>> response = pyip.inputURL() google.com >>> response 'google.com' >>> response = pyip.inputURL() mailto:al@inventwithpython.com >>> response 'mailto:al@inventwithpython.com'
-
pyinputplus.
inputYesNo
(prompt='', yesVal='yes', noVal='no', caseSensitive=False, default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a yes/no response. The user can also enter y/n and use any case. Returns the
yesVal
ornoVal
argument (which default to'yes'
and'no'
), depending on the user’s selection.Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputYesNo() yes >>> response 'yes' >>> response = pyip.inputYesNo() NO >>> response 'no' >>> response = pyip.inputYesNo() Y >>> response 'yes' >>> response = pyip.inputYesNo(yesVal='oui', noVal='no') oui >>> response 'oui'
-
pyinputplus.
inputBool
(prompt='', trueVal='True', falseVal='False', caseSensitive=False, default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a True/False response. The user can also enter t/f and in any case. Returns a boolean value.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputBool() true >>> response True >>> type(response) <class 'bool'> >>> response = pyip.inputBool() F >>> response False
-
pyinputplus.
inputZip
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a 3 to 5-digit US zip code. Returns the zipcode as a string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.
-
pyinputplus.
inputFilename
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a filename. Filenames can’t contain / : * ? ” < > | or end with a space. Note that this validates filenames, not filepaths. The / and characters are invalid for filenames. Returns the filename as a string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.
-
pyinputplus.
inputFilepath
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None, mustExist=False)¶ Prompts the user to enter a filepath. If mustExist is True, then this filepath must exist on the local filesystem. Returns the filepath as a string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.
-
pyinputplus.
inputEmail
(prompt='', default=None, blank=False, timeout=None, limit=None, strip=None, allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter an email address. Returns the email address as a string.
Run
help(pyinputplus.parameters)
for an explanation of the common parameters.>>> import pyinputplus as pyip >>> response = pyip.inputEmail() hello world 'hello world' is not a valid email address. al@inventwithpython.com >>> response 'al@inventwithpython.com'
-
pyinputplus.
inputPassword
(prompt='', mask='*', default=None, blank=False, timeout=None, limit=None, strip='', allowRegexes=None, blockRegexes=None, applyFunc=None, postValidateApplyFunc=None)¶ Prompts the user to enter a password. Mask characters will be displayed instead of the actual characters. If
correctPassword
isNone
, then any input is accepted and returned byinputPassword()
. The default for strip is''
so that no whitespace striping occurs.By default,
limit
is set to 1, so an incorrect password attempt results in raisingRetryLimitException
. Iflimit
is set toNone
, then user is asked again for a correct password forever. ThewrongPasswordMsg
string is displayed whenever the user enters an incorrect password.If
correctPassword
is set to None, all input is accepted.The
mask
is the character used to display instead of the actual keystrokes. It can be set toNone
(don’t hide keystrokes), a blank string (don’t show anything as the user types), or a single-character string (show this character instead of the keystroke). It can’t be set to a multi-character string.Run
help(pyinputplus.parameters)
for an explanation of the common parameters.