inpInt

Module Contents

class inpInt.inpInt(inputStr)

Bases: int

An inpInt object behaves like a regular int, except it has a new attribute _formatStr. This attribute is used to create exact string representations of the original object.

static __new__(inputStr)

Creates the inpInt instance.

__init__(inputStr)

__init__(inputStr)

Initializes the inpInt instance, 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 typical int operations will work:

>>> num2 = inpInt('  2 ')
>>> num1 + num2
4

Please note that most int operations will produce a int, not a inpInt:

>>> 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:

str

_outstr()

Generates the output string.

Example usage:

>>> from inpInt import inpInt
>>> str(inpInt('  2 '))
'  2 '
Returns:

The string in the original formatting.

Return type:

str

__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

__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:

str

__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