home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pyos2bin.zip / Lib / types.py < prev    next >
Text File  |  1997-09-29  |  1KB  |  65 lines

  1. # Define names for all type symbols known in the standard interpreter.
  2. # Types that are part of optional modules (e.g. array) are not listed.
  3.  
  4. import sys
  5.  
  6. NoneType = type(None)
  7. TypeType = type(NoneType)
  8.  
  9. IntType = type(0)
  10. LongType = type(0L)
  11. FloatType = type(0.0)
  12. try:
  13.     ComplexType = type(complex(0,1))
  14. except NameError:
  15.     pass
  16.  
  17. StringType = type('')
  18.  
  19. TupleType = type(())
  20. ListType = type([])
  21. DictType = DictionaryType = type({})
  22.  
  23. def _f(): pass
  24. FunctionType = type(_f)
  25. LambdaType = type(lambda: None)        # Same as FunctionType
  26. try:
  27.     CodeType = type(_f.func_code)
  28. except:
  29.     pass
  30.  
  31. class _C:
  32.     def _m(self): pass
  33. ClassType = type(_C)
  34. UnboundMethodType = type(_C._m)        # Same as MethodType
  35. _x = _C()
  36. InstanceType = type(_x)
  37. MethodType = type(_x._m)
  38.  
  39. BuiltinFunctionType = type(len)
  40. BuiltinMethodType = type([].append)    # Same as BuiltinFunctionType
  41.  
  42. ModuleType = type(sys)
  43.  
  44. try:
  45.     FileType = type(sys.stdin)        # XXX what if it was assigned to?
  46. except:
  47.     pass
  48. XRangeType = type(xrange(0))
  49.  
  50. try:
  51.     raise TypeError
  52. except TypeError:
  53.     try:
  54.     tb = sys.exc_info()[2]
  55.     TracebackType = type(tb)
  56.     FrameType = type(tb.tb_frame)
  57.     except:
  58.     pass
  59.     tb = None; del tb
  60.  
  61. SliceType = type(slice(0))
  62. EllipsisType = type(Ellipsis)
  63.  
  64. del sys, _f, _C, _x            # Not for export
  65.