inpInt¶
Module Contents¶
- class inpInt.inpInt(inputStr)¶
Bases:
intAn
inpIntobject behaves like a regularint, except it has a new attribute_formatStr. This attribute is used to create exact string representations of the original object.- __init__(inputStr)¶
__init__(inputStr)
Initializes the
inpIntinstance, represented by inputStr. Parses the integer value contained in inputStr, and also tracks any whitespace characters included in inputStr.Example usage:
>>> from inpInt import inpInt >>> num1 = inpInt(' 2 ') >>> num1 inpInt(' 2 ') >>> str(num1) ' 2 '
Since an
inpInt, all of the typicalintoperations will work:>>> num2 = inpInt(' 2 ') >>> num1 + num2 4
Please note that most
intoperations will produce aint, not ainpInt:>>> type(num1 + num2) <class 'int'>
- Parameters:
inputStr (str) – The string containing an integer which will be parsed, maintaining the original formatting.
- _formatStr¶
Stores the whitespace information of inputStr, with placeholder symbols (“%s”) where the integer value should be reinserted. Will include leading 0s, the positive sign, or the negative sign if it precedes leading 0s.
- _outstr_lead0()¶
Generates the output string for cases which include a leading 0.
Example usage:
>>> from inpInt import inpInt >>> str(inpInt(' -01')) ' -01'
- Returns:
The string in the original formatting.
- Return type:
- _outstr()¶
Generates the output string.
Example usage:
>>> from inpInt import inpInt >>> str(inpInt(' 2 ')) ' 2 '
- Returns:
The string in the original formatting.
- Return type:
- __repr__()¶
Creates a string representation which can be used to recreate the object.
Example usage:
>>> from inpInt import inpInt >>> inpInt(' 2 ') inpInt(' 2 ')
- Return type:
- __str__()¶
Calls
_outstr()to create a string of object in the original formatting.Example usage:
>>> from inpInt import inpInt >>> str(inpInt(' 2 ')) ' 2 '
- Return type:
- __getnewargs__()¶
This function is required so the class can pickle/unpickle properly. This enables multiprocessing.
Example
>>> from inpInt import inpInt >>> inpInt(' 2 ').__getnewargs__() (' 2 ',)
- Returns:
tuple