Your class.function
expects an integer which can be represented either by a decimal or a hexadecimal literal, so that these two calls are completely equivalent:
class.function(0x77)
class.function(119) # 0x77 == 119
Even print(0x77)
will show 119
(because decimal is the default representation).
So, we should rather be talking about converting a string representation to integer. The string can be a hexadecimal representation, like '0x77', then parse it with the base parameter:
>>> int('0x77', 16)
119
or a decimal one, then parse it as int('119')
.
Still, storing integer whenever you deal with integers is better.
EDIT: as @gnibbler suggested, you can parse as int(x, 0)
, which handles both formats.