Working on an application that has a function that takes in a value and I am trying to see if it is an int
, float
or string
. After doing some looking online I found isnumeric()
and isdigit()
to cover both int and float scenarios and string is default.
Brilliant... problem solved :)
Well not quite! Because this app supports Python versions 2.7.15
, 3.4.8
, 3.5.5
, 3.6.6
and I learned that for Python 2 isnumeric and isdigit works on unicode while Python 3 it works on strings.
So I have my CI passing the tests for Python 3 but failing for Python 2 :(
Is there a way to check what version of Python is being ran dynamically and from there use the correct implementation of the functions?