PyXR

c:\python24\lib \ types.py



0001 """Define names for all type symbols known in the standard interpreter.
0002 
0003 Types that are part of optional modules (e.g. array) are not listed.
0004 """
0005 import sys
0006 
0007 # Iterators in Python aren't a matter of type but of protocol.  A large
0008 # and changing number of builtin types implement *some* flavor of
0009 # iterator.  Don't check the type!  Use hasattr to check for both
0010 # "__iter__" and "next" attributes instead.
0011 
0012 NoneType = type(None)
0013 TypeType = type
0014 ObjectType = object
0015 
0016 IntType = int
0017 LongType = long
0018 FloatType = float
0019 BooleanType = bool
0020 try:
0021     ComplexType = complex
0022 except NameError:
0023     pass
0024 
0025 StringType = str
0026 
0027 # StringTypes is already outdated.  Instead of writing "type(x) in
0028 # types.StringTypes", you should use "isinstance(x, basestring)".  But
0029 # we keep around for compatibility with Python 2.2.
0030 try:
0031     UnicodeType = unicode
0032     StringTypes = (StringType, UnicodeType)
0033 except NameError:
0034     StringTypes = (StringType,)
0035 
0036 BufferType = buffer
0037 
0038 TupleType = tuple
0039 ListType = list
0040 DictType = DictionaryType = dict
0041 
0042 def _f(): pass
0043 FunctionType = type(_f)
0044 LambdaType = type(lambda: None)         # Same as FunctionType
0045 try:
0046     CodeType = type(_f.func_code)
0047 except RuntimeError:
0048     # Execution in restricted environment
0049     pass
0050 
0051 def _g():
0052     yield 1
0053 GeneratorType = type(_g())
0054 
0055 class _C:
0056     def _m(self): pass
0057 ClassType = type(_C)
0058 UnboundMethodType = type(_C._m)         # Same as MethodType
0059 _x = _C()
0060 InstanceType = type(_x)
0061 MethodType = type(_x._m)
0062 
0063 BuiltinFunctionType = type(len)
0064 BuiltinMethodType = type([].append)     # Same as BuiltinFunctionType
0065 
0066 ModuleType = type(sys)
0067 FileType = file
0068 XRangeType = xrange
0069 
0070 try:
0071     raise TypeError
0072 except TypeError:
0073     try:
0074         tb = sys.exc_info()[2]
0075         TracebackType = type(tb)
0076         FrameType = type(tb.tb_frame)
0077     except AttributeError:
0078         # In the restricted environment, exc_info returns (None, None,
0079         # None) Then, tb.tb_frame gives an attribute error
0080         pass
0081     tb = None; del tb
0082 
0083 SliceType = slice
0084 EllipsisType = type(Ellipsis)
0085 
0086 DictProxyType = type(TypeType.__dict__)
0087 NotImplementedType = type(NotImplemented)
0088 
0089 del sys, _f, _g, _C, _x                  # Not for export
0090 

Generated by PyXR 0.9.4
SourceForge.net Logo