Clinput package¶
Single Input¶
clinput.single module¶
-
clinput.single.
boolean
(message, err='Please enter 1 (True) or 0 (False).')¶ Command line input and error checking for boolean values (1 or 0).
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please enter 1 (True) or 0 (False).”.
Returns: The first sucessfully input boolean value.
Return type: bool
-
clinput.single.
custom
(message, allowed, err='Invalid input.')¶ Command line input and error checking for user-defined allowable inputs.
Parameters: - message (str) – The input message displayed in the command line.
- allowed (tuple of (str,)) – The allowable user inputs.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Invalid input.”.
Returns: The first sucessfully allowed input string.
Return type: str
-
clinput.single.
integer
(message, err='Please enter an integer.')¶ Command line input and error checking for integers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please enter an integer.”.
Returns: The first sucessfully input integer.
Return type: int
-
clinput.single.
natural
(message, err='Please enter an integer greater than zero.', zero=False)¶ Command line input and error checking for natural numbers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please enter an integer greater than zero.”.
- zero (bool, optional) – Zero status. True includes zero, False excludes zero. Defaults to False.
Returns: The first sucessfully input natural number.
Return type: int
-
clinput.single.
negative
(message, err='Please enter a negative number.', zero=True)¶ Command line input and error checking for negative numbers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please enter a negative number.”.
- zero (bool, optional) – Zero status. True includes zero, False excludes zero. Defaults to True.
Returns: The first sucessfully input negative number.
Return type: float
-
clinput.single.
number
(message, err='Please enter a number.')¶ Command line input and error checking for numbers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please enter a number.”.
Returns: The first sucessfully input number.
Return type: float
-
clinput.single.
positive
(message, err='Please enter a positive number.', zero=True)¶ Command line input and error checking for positive numbers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please enter a positive number.”.
- zero (bool, optional) – Zero status. True includes zero, False excludes zero. Defaults to True.
Returns: The first sucessfully input positive number.
Return type: float
-
clinput.single.
string
(message, err='Please provide an input.')¶ Command line input and error checking for strings (error if blank).
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please provide an input.”.
Returns: The first sucessfully input string.
Return type: str
Multiple Input¶
clinput.multi module¶
-
clinput.multi.
boolean
(message, err='Please only enter 1s (True) or 0s (False).', sep=' ')¶ Command line input and error checking for boolean values (1 or 0).
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please only enter 1s (True) or 0s (False).”.
- sep (str, optional) – The character used to separate inputs. Defaults to ” “.
Returns: The first sucessfully input list of boolean values.
Return type: list of [bool,]
-
clinput.multi.
custom
(message, allowed, err='Invalid input.', sep=' ')¶ Command line input and error checking for user-defined allowable inputs.
Parameters: - message (str) – The input message displayed in the command line.
- allowed (tuple of (str,)) – The allowable user inputs.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Invalid input.”.
- sep (str, optional) – The character used to separate inputs. Defaults to ” “.
Returns: The first sucessfully input list of allowed strings.
Return type: list of [str,]
-
clinput.multi.
integer
(message, err='Please only enter integers.', sep=' ')¶ Command line input and error checking for integers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please only enter integers.”.
- sep (str, optional) – The character used to separate inputs. Defaults to ” “.
Returns: The first sucessfully input list of integers.
Return type: list of [int,]
-
clinput.multi.
natural
(message, err='Please only enter positive integers.', zero=False, sep=' ')¶ Command line input and error checking for natural numbers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please only enter positive integers.”.
- zero (bool, optional) – Zero status. True includes zero, False excludes zero. Defaults to False.
- sep (str, optional) – The character used to separate inputs. Defaults to ” “.
Returns: The first sucessfully input list of natural numbers.
Return type: list of [int,]
-
clinput.multi.
negative
(message, err='Please only enter negative numbers.', zero=True, sep=' ')¶ Command line input and error checking for negative numbers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please only enter negative numbers.”.
- zero (bool, optional) – Zero status. True includes zero, False excludes zero. Defaults to True.
- sep (str, optional) – The character used to separate inputs. Defaults to ” “.
Returns: The first sucessfully input list of negative numbers.
Return type: list of [float,]
-
clinput.multi.
number
(message, err='Please only enter numbers.', sep=' ')¶ Command line input and error checking for numbers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please only enter numbers.”.
- sep (str, optional) – The character used to separate inputs. Defaults to ” “.
Returns: The first sucessfully input list of numbers.
Return type: list of [float,]
-
clinput.multi.
positive
(message, err='Please only enter positive numbers.', zero=True, sep=' ')¶ Command line input and error checking for positive numbers.
Parameters: - message (str) – The input message displayed in the command line.
- err (str, optional) – The message displayed for an erroneous input. Defaults to “Please only enter positive numbers.”.
- zero (bool, optional) – Zero status. True includes zero, False excludes zero. Defaults to True.
- sep (str, optional) – The character used to separate inputs. Defaults to ” “.
Returns: The first sucessfully input list of positive numbers.
Return type: list of [float,]