Fix the availability statement for the spawn*() functions to reflect the
[python/dscho.git] / Lib / types.py
blob8a07950f7e98bf1588b92376052baf9887e1c059
1 """Define names for all type symbols known in the standard interpreter.
3 Types that are part of optional modules (e.g. array) are not listed.
4 """
5 from __future__ import generators
7 import sys
9 # Iterators in Python aren't a matter of type but of protocol. A large
10 # and changing number of builtin types implement *some* flavor of
11 # iterator. Don't check the type! Use hasattr to check for both
12 # "__iter__" and "next" attributes instead.
14 NoneType = type(None)
15 TypeType = type
16 ObjectType = object
18 IntType = int
19 LongType = long
20 FloatType = float
21 try:
22 ComplexType = complex
23 except NameError:
24 pass
26 StringType = str
27 try:
28 UnicodeType = unicode
29 StringTypes = (StringType, UnicodeType)
30 except NameError:
31 StringTypes = (StringType,)
33 BufferType = type(buffer(''))
35 TupleType = tuple
36 ListType = list
37 DictType = DictionaryType = dict
39 def _f(): pass
40 FunctionType = type(_f)
41 LambdaType = type(lambda: None) # Same as FunctionType
42 try:
43 CodeType = type(_f.func_code)
44 except RuntimeError:
45 # Execution in restricted environment
46 pass
48 def g():
49 yield 1
50 GeneratorType = type(g())
51 del g
53 class _C:
54 def _m(self): pass
55 ClassType = type(_C)
56 UnboundMethodType = type(_C._m) # Same as MethodType
57 _x = _C()
58 InstanceType = type(_x)
59 MethodType = type(_x._m)
61 BuiltinFunctionType = type(len)
62 BuiltinMethodType = type([].append) # Same as BuiltinFunctionType
64 ModuleType = type(sys)
65 FileType = file
66 XRangeType = type(xrange(0))
68 try:
69 raise TypeError
70 except TypeError:
71 try:
72 tb = sys.exc_info()[2]
73 TracebackType = type(tb)
74 FrameType = type(tb.tb_frame)
75 except AttributeError:
76 # In the restricted environment, exc_info returns (None, None,
77 # None) Then, tb.tb_frame gives an attribute error
78 pass
79 tb = None; del tb
81 SliceType = type(slice(0))
82 EllipsisType = type(Ellipsis)
84 DictProxyType = type(TypeType.__dict__)
86 del sys, _f, _C, _x, generators # Not for export