1.工厂函数
函数生成实例,一种常见的书籍模式
2.类型工厂函数
>>> a = int(9.9)
>>> a # 9
>>> b = float(8)
>>> b # 8.0
>>> c = complex(7)
>>> c # (7+0j)
>>> d = bool(None)
>>> d # False
>>> s = str(9.9)
>>> s # '9.9'
>>> l = list('python')
>>> l # ['p', 'y', 't', 'h', 'o', 'n']
>>> dt = dict(a=1)
>>> dt # {'a': 1}
>>> s=set('python')
>>> s # set(['h', 'o', 'n', 'p', 't', 'y'])
>>> s=frozenset('python')
>>> s # frozenset(['h', 'o', 'n', 'p', 't', 'y'])
查看类型
>>>a = type(6)
>>> a # <type 'int'>