parse_int#
- hexrec.utils.parse_int(value)[source]#
Parses an integer.
- Parameters:
value (
Union
[str
,Any
]) – A generic object to convert to integer. In case value is astr
(case-insensitive), it can be either prefixed with0x
or postfixed withh
to convert from a hexadecimal representation, or prefixed with0b
from binary; a prefix of only0
converts from octal. A further suffix applies a scale factor as perSUFFIX_SCALE
. ANone
value evaluates asNone
. Any other object class will call the standardint()
.- Returns:
int – None if value is
None
, its integer conversion otherwise.
Examples
>>> parse_int('-0xABk') -175104
>>> parse_int(None) is None True
>>> parse_int(123) 123
>>> parse_int(135.7) 135