Today I am a long knowledge, I am a Python rookie, has always been that type (a) can return the type of a, but do not know that type can also be used to create class, this experience is to describe how to create a class with the type (), and how to set the properties of the class.
We use the type to create an empty class: There is only one name, nothing else, and its parameter format is: Type (class_name,bases,dic)
Let's use type to see the type of CLS we create:
View the name of the CLS
If we create a class with a familiar inheritance, it is the same as the CLS:
Of course, we can set the properties of any other class by using the parameter dic, for example:
CLS2 now has more properties than CLS __doc__,__module__
The type of a ——————————————————————————— type () ————————————————————————————
IDLE 2.6. 6
>>> type(None)
<type ' Nonetype '>
>>> type(False)
<type ' bool '>
>>> type(123)
<type ' int '>
>>> type(0.1)
<type ' float '>
>>> type(0L)
<type ' Long '>
>>> type(0.0+0.1j)
<type ' complex '> #复数
>>> type ("Markro")
<type ' str '>
>>> type(["Markro","loverobey.blog.163.com"])
<type ' list '> #列表
>>> type (("A", "B")
<type ' tuple '> #元组
>>> type ({' X ': 1})
<type ' dict '> #字典
>>> type (Type ("Markro"))
<type ' type '>