Lad said:
Hello
How can I find out in Python whether the operand is integer or a
character and change from char to int ?
Regards,
L.
You may want to try the "type" command.
And there is no character type in cPython (unless you're using ctypes
that is)
There is not much point though, you can use the "int" construct on your
expression, Python'll try to convert the expression to an integer by
itself (and throw an exception if it can't)
Traceback (most recent call last):
File "<pyshell#5>", line 1, in -toplevel-
int(a)
ValueError: invalid literal for int(): e
You can even do base conversions with it:
Traceback (most recent call last):
File "<pyshell#7>", line 1, in -toplevel-
int(a)
ValueError: invalid literal for int(): 0xe