Jun-03-2019, 04:32 AM
i want to convert a number that has a suffix following the digits. i think i will need to split it at the point where the digits end and the suffix begins. the tool to convert ints in C (strtol) can also yield a pointer to where the digits end. int() in Python does not do that and will even fail the conversion if any non-digits follow the digits. i want to convert strings like '5m' and extract the suffix to work with that.
'm'
can mean minutes, and with a map having 'm':60
multiply the 5 to get 300. i'd like to also support other bases like int(digits,0)
does, as long as the suffix characters are not the same as any digits in that base (like not using 'd' as a suffix for hexadecimal). any suggestions? this is one of the things i need to limit to what is in the Python library itself.