How to determine a Python variable's type?
type() builtin function:
123type(i)<type 'int'>type(i) is intTruei = 123.456type(i)<type 'float'>type(i) is floatTruei =
To check if a variable is of a given type, use
123isinstance(i, int)Trueisinstance(i, (float, str, set, dict))Falsei =
Note that Python doesn't have the same types as C/C++, which appears to be your question.
You may be looking for the
type() built-in function.
See the examples below, but there's no "unsigned" type in Python just like Java.
10type(v)<type 'int'>v =
Large positive integer:
100000000000000type(v)<type 'long'>v =
10type(v)<type 'int'>v = -
Literal sequence of characters:
'hi'type(v)<type 'str'>v =
Floating point integer:
3.14159type(v)<type 'float'>v =