data (type|structure) in Python of a name generally a variable
Every type is an object in Python (except for type). ints, strings, functions and classes are objects and have been created from a class.
my_int = 7
my_bool = True
Comparing objects of different types is legal. See Comparing objects
with the type function
print type(1)
print type(1.23)
print type('string')
print type({'Name':'John Cleese'})
print type((1,2))
<type 'int'>
<type 'float'>
<type 'unicode'>
<type 'dict'>
<type 'tuple'>
The 'unicode' type is a special type of string.
if (type(p1) == int or type(p1) == float):
return "An integer or float!"
else:
return "Not an integer or float!"
if isinstance(p1,str):
return "An string !"
if isinstance(p1,module.myclass):
return "It's an instance of module.myclass"