In [1]:
print(type('string'))


<class 'str'>

In [2]:
print(type(100))


<class 'int'>

In [3]:
print(type([0, 1, 2]))


<class 'list'>

In [4]:
print(type(type('string')))


<class 'type'>

In [5]:
print(type(str))


<class 'type'>

In [6]:
print(type('string') is str)


True

In [7]:
print(type('string') is int)


False

In [8]:
def is_str(v):
    return type(v) is str

In [9]:
print(is_str('string'))


True

In [10]:
print(is_str(100))


False

In [11]:
print(is_str([0, 1, 2]))


False

In [12]:
def is_str_or_int(v):
    return type(v) in (str, int)

In [13]:
print(is_str_or_int('string'))


True

In [14]:
print(is_str_or_int(100))


True

In [15]:
print(is_str_or_int([0, 1, 2]))


False

In [16]:
def type_condition(v):
    if type(v) is str:
        print('type is str')
    elif type(v) is int:
        print('type is int')
    else:
        print('type is not str or int')

In [17]:
type_condition('string')


type is str

In [18]:
type_condition(100)


type is int

In [19]:
type_condition([0, 1, 2])


type is not str or int