* `inputYesNo()` - Accepts a case-insensitive form of `'Yes'`, `'Y'`, `'No'`, or `'N'` and returns `'yes'` or `'no'`.- Bitcode files of additional native objects. (This has several common formats by default.) Returns a `datetime.time` object. * `inputTime()` - Same as `inputDate()`, except it handles times. (This has several common formats by default.) Returns a `datetime.datetime` object. * `inputDatetime()` - Same as `inputDate()`, except it handles dates and times. (This has several common formats by default.) Returns a `datetime.date` object. * `inputDate()` - Accepts a date typed in one of the `strftime` formats passed to the `formats` parameter. options if `numbered` or `lettered` are set to `True`. * `inputMenu()` - Similar to `inputChoice()`, but will also present the choices in a menu with 1, 2, 3. * `inputChoice()` - Accepts one of the strings in the list of strings passed for its `choices` parameter. * `inputBool()` - Accepts a case-insensitive form of `'True'`, `'T'`, `'False'`, or `'F'` and returns a bool value. Also has `min`/`max`/`greaterThan`/`lessThan` parameters. * `inputFloat()` - Accepts a floating-point number. * `inputInt()` - Accepts an integer number. Additionally has `min` and `max` parameters for inclusive bounds and `greaterThan` and `lessThan` parameters for exclusive bounds. * `inputNum()` - Accepts a numeric number. Use this if you basically want Python's `input()` or `raw_input()`, but with PyInputPlus features such as whitelist/blacklist, timeouts, limits, etc. Other input functions may have additional parameters. * `postValidateApplyFunc` (Callable): 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. (The return value of this function is ignored.) * `validationFunc` (Callable): A function that is passed the user's input value, which raises an exception if the input isn't valid. * `applyFunc` (Callable, None): An optional function that is passed the user's input, and returns the new value to use as the input. * `blacklistRegexes` (Sequence, None): A sequence of regex str or (regex_str, response_str) tuples that, if matched, will explicitly fail validation. * `whitelistRegexes` (Sequence, None): A sequence of regex str that will explicitly pass validation, even if they aren't numbers. If a str, the characters in it are stripped from value. * `strip` (bool, str, None): If `True`, whitespace is stripped from `value`. * `limit` (int): The number of tries the user has to enter valid input before the default value is returned. * `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. * `blank` (bool): If `True`, blank strings will be allowed as valid user input. * `default` (str, None): A default value to use should the user time out or exceed the number of tries to enter valid input. Identical to the prompt argument for Python's `raw_input()` and `input()` functions. * `prompt` (str): The text to display before each prompt for user input. > result = inputMenu(, lettered=True, numbered=False)Īll input functions have the following parameters: > result = pyip.inputStr('Favorite animal> ', blacklistRegexes=) > result = pyip.inputNum(greaterThan=4, lessThan=6) * Allowing case-sensitive or case-insensitive responses. * Presenting menus with bulleted, lettered, or numbered options. * Specifying regexes for whitelists or blacklists of responses. * Timeouts or retry limits for user responses. * Validating for numeric, boolean, date, time, or yes/no responses. * Re-prompting the user if they enter invalid input. A Python 2 and 3 module to provide input()- and raw_input()-like functions with additional validation features, including:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |