diff options
| author | Guido van Rossum <guido@python.org> | 1994-06-23 11:53:27 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 1994-06-23 11:53:27 +0000 |
| commit | 85d894559029cad1e5ed0f71b9a63242d4631b87 (patch) | |
| tree | fe4e7b8d9525dd870acbad740aba27b3bfb2bb0d /Lib/types.py | |
| parent | adb3105ec413bd29b3d7ce40a133ef600caa4e56 (diff) | |
| download | cpython-git-85d894559029cad1e5ed0f71b9a63242d4631b87.tar.gz | |
Two new generally useful modules: types defines names for all built-in types,
StringIO implements pseudo files writing into and reading from strings.
Diffstat (limited to 'Lib/types.py')
| -rw-r--r-- | Lib/types.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Lib/types.py b/Lib/types.py new file mode 100644 index 0000000000..531d4050e7 --- /dev/null +++ b/Lib/types.py @@ -0,0 +1,43 @@ +# Define names for all type symbols known in the standard interpreter. +# Types that are part of optional modules (e.g. array) are not listed. + +import sys + +NoneType = type(None) +TypeType = type(NoneType) + +IntType = type(0) +LongType = type(0L) +FloatType = type(0.0) + +StringType = type('') + +TupleType = type(()) +ListType = type([]) +DictionaryType = type({}) + +def func(): pass +FunctionType = type(func) + +class C: + def meth(self): pass +ClassType = type(C) +UnboundMethodType = type(C.meth) # Same as MethodType +x = C() +InstanceType = type(x) +MethodType = type(x.meth) + +BuiltinFunctionType = type(len) # Also used for built-in methods + +ModuleType = type(sys) + +FileType = type(sys.stdin) +XRangeType = type(xrange(0)) + +try: + raise TypeError +except TypeError: + TracebackType = type(sys.exc_traceback) + FrameType = type(sys.exc_traceback.tb_frame) + +del sys, func, C, x # These are not for export |
