Hugh
0
Q:

type of object python

print(type('string'))
# <class 'str'>

print(type('string') is str)
# True
2
>>> type([]) is list
True
>>> type({}) is dict
True
>>> type('') is str
True
>>> type(0) is int
True
5
# Python code for type() with a name,  
# bases and dict parameter 
  
o1 = type('X', (object,), dict(a='Foo', b=12)) 
  
print(type(o1)) 
print(vars(o1)) 
  
class test: 
      a = 'Foo'
  b = 12
    
o2 = type('Y', (test,), dict(a='Foo', b=12)) 
print(type(o2)) 
print(vars(o2)) 
0

New to Communities?

Join the community