home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pytho152.zip / emx / lib / python1.5 / types.py < prev    next >
Text File  |  2000-08-10  |  1KB  |  66 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. BufferType = type(buffer(''))
  19.  
  20. TupleType = type(())
  21. ListType = type([])
  22. DictType = DictionaryType = type({})
  23.  
  24. def _f(): pass
  25. FunctionType = type(_f)
  26. LambdaType = type(lambda: None)         # Same as FunctionType
  27. try:
  28.     CodeType = type(_f.func_code)
  29. except:
  30.     pass
  31.  
  32. class _C:
  33.     def _m(self): pass
  34. ClassType = type(_C)
  35. UnboundMethodType = type(_C._m)         # Same as MethodType
  36. _x = _C()
  37. InstanceType = type(_x)
  38. MethodType = type(_x._m)
  39.  
  40. BuiltinFunctionType = type(len)
  41. BuiltinMethodType = type([].append)     # Same as BuiltinFunctionType
  42.  
  43. ModuleType = type(sys)
  44.  
  45. try:
  46.     FileType = type(sys.__stdin__)
  47. except:
  48.     pass
  49. XRangeType = type(xrange(0))
  50.  
  51. try:
  52.     raise TypeError
  53. except TypeError:
  54.     try:
  55.         tb = sys.exc_info()[2]
  56.         TracebackType = type(tb)
  57.         FrameType = type(tb.tb_frame)
  58.     except:
  59.         pass
  60.     tb = None; del tb
  61.  
  62. SliceType = type(slice(0))
  63. EllipsisType = type(Ellipsis)
  64.  
  65. del sys, _f, _C, _x                     # Not for export
  66.