]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.10/Lib/types.py
AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 4/5.
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Lib / types.py
CommitLineData
3257aa99
DM
1"""Define names for all type symbols known in the standard interpreter.\r
2\r
3Types that are part of optional modules (e.g. array) are not listed.\r
4"""\r
5import sys\r
6\r
7# Iterators in Python aren't a matter of type but of protocol. A large\r
8# and changing number of builtin types implement *some* flavor of\r
9# iterator. Don't check the type! Use hasattr to check for both\r
10# "__iter__" and "next" attributes instead.\r
11\r
12NoneType = type(None)\r
13TypeType = type\r
14ObjectType = object\r
15\r
16IntType = int\r
17LongType = long\r
18FloatType = float\r
19BooleanType = bool\r
20try:\r
21 ComplexType = complex\r
22except NameError:\r
23 pass\r
24\r
25StringType = str\r
26\r
27# StringTypes is already outdated. Instead of writing "type(x) in\r
28# types.StringTypes", you should use "isinstance(x, basestring)". But\r
29# we keep around for compatibility with Python 2.2.\r
30try:\r
31 UnicodeType = unicode\r
32 StringTypes = (StringType, UnicodeType)\r
33except NameError:\r
34 StringTypes = (StringType,)\r
35\r
36BufferType = buffer\r
37\r
38TupleType = tuple\r
39ListType = list\r
40DictType = DictionaryType = dict\r
41\r
42def _f(): pass\r
43FunctionType = type(_f)\r
44LambdaType = type(lambda: None) # Same as FunctionType\r
45CodeType = type(_f.func_code)\r
46\r
47def _g():\r
48 yield 1\r
49GeneratorType = type(_g())\r
50\r
51class _C:\r
52 def _m(self): pass\r
53ClassType = type(_C)\r
54UnboundMethodType = type(_C._m) # Same as MethodType\r
55_x = _C()\r
56InstanceType = type(_x)\r
57MethodType = type(_x._m)\r
58\r
59BuiltinFunctionType = type(len)\r
60BuiltinMethodType = type([].append) # Same as BuiltinFunctionType\r
61\r
62ModuleType = type(sys)\r
63FileType = file\r
64XRangeType = xrange\r
65\r
66try:\r
67 raise TypeError\r
68except TypeError:\r
69 tb = sys.exc_info()[2]\r
70 TracebackType = type(tb)\r
71 FrameType = type(tb.tb_frame)\r
72 del tb\r
73\r
74SliceType = slice\r
75EllipsisType = type(Ellipsis)\r
76\r
77DictProxyType = type(TypeType.__dict__)\r
78NotImplementedType = type(NotImplemented)\r
79\r
80# For Jython, the following two types are identical\r
81GetSetDescriptorType = type(FunctionType.func_code)\r
82MemberDescriptorType = type(FunctionType.func_globals)\r
83\r
84del sys, _f, _g, _C, _x # Not for export\r
85\r
86__all__ = list(n for n in globals() if n[:1] != '_')\r