| 1 |
"""Define names for all type symbols known in the standard interpreter. |
| 2 |
|
| 3 |
Types that are part of optional modules (e.g. array) are not listed. |
| 4 |
""" |
| 5 |
import sys |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
NoneType = type(None) |
| 13 |
TypeType = type |
| 14 |
ObjectType = object |
| 15 |
|
| 16 |
IntType = int |
| 17 |
LongType = long |
| 18 |
FloatType = float |
| 19 |
BooleanType = bool |
| 20 |
try: |
| 21 |
ComplexType = complex |
| 22 |
except NameError: |
| 23 |
pass |
| 24 |
|
| 25 |
StringType = str |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
try: |
| 31 |
UnicodeType = unicode |
| 32 |
StringTypes = (StringType, UnicodeType) |
| 33 |
except NameError: |
| 34 |
StringTypes = (StringType,) |
| 35 |
|
| 36 |
BufferType = buffer |
| 37 |
|
| 38 |
TupleType = tuple |
| 39 |
ListType = list |
| 40 |
DictType = DictionaryType = dict |
| 41 |
|
| 42 |
def _f(): pass |
| 43 |
FunctionType = type(_f) |
| 44 |
LambdaType = type(lambda: None) |
| 45 |
CodeType = type(_f.func_code) |
| 46 |
|
| 47 |
def _g(): |
| 48 |
yield 1 |
| 49 |
GeneratorType = type(_g()) |
| 50 |
|
| 51 |
class _C: |
| 52 |
def _m(self): pass |
| 53 |
ClassType = type(_C) |
| 54 |
UnboundMethodType = type(_C._m) |
| 55 |
_x = _C() |
| 56 |
InstanceType = type(_x) |
| 57 |
MethodType = type(_x._m) |
| 58 |
|
| 59 |
BuiltinFunctionType = type(len) |
| 60 |
BuiltinMethodType = type([].append) |
| 61 |
|
| 62 |
ModuleType = type(sys) |
| 63 |
FileType = file |
| 64 |
XRangeType = xrange |
| 65 |
|
| 66 |
try: |
| 67 |
raise TypeError |
| 68 |
except TypeError: |
| 69 |
tb = sys.exc_info()[2] |
| 70 |
TracebackType = type(tb) |
| 71 |
FrameType = type(tb.tb_frame) |
| 72 |
del tb |
| 73 |
|
| 74 |
SliceType = slice |
| 75 |
EllipsisType = type(Ellipsis) |
| 76 |
|
| 77 |
DictProxyType = type(TypeType.__dict__) |
| 78 |
NotImplementedType = type(NotImplemented) |
| 79 |
|
| 80 |
|
| 81 |
GetSetDescriptorType = type(FunctionType.func_code) |
| 82 |
MemberDescriptorType = type(FunctionType.func_globals) |
| 83 |
|
| 84 |
del sys, _f, _g, _C, _x |
| 85 |
|
| 86 |
__all__ = list(n for n in globals() if n[:1] != '_') |