Merged revisions 75928 via svnmerge from
[python/dscho.git] / Lib / types.py
blobab354d1a715d9f7e13acc6aa8e89cb520f3a8280
1 """
2 Define names for built-in types that aren't directly accessible as a builtin.
3 """
4 import sys
6 # Iterators in Python aren't a matter of type but of protocol. A large
7 # and changing number of builtin types implement *some* flavor of
8 # iterator. Don't check the type! Use hasattr to check for both
9 # "__iter__" and "__next__" attributes instead.
11 def _f(): pass
12 FunctionType = type(_f)
13 LambdaType = type(lambda: None) # Same as FunctionType
14 CodeType = type(_f.__code__)
16 def _g():
17 yield 1
18 GeneratorType = type(_g())
20 class _C:
21 def _m(self): pass
22 MethodType = type(_C()._m)
24 BuiltinFunctionType = type(len)
25 BuiltinMethodType = type([].append) # Same as BuiltinFunctionType
27 ModuleType = type(sys)
29 try:
30 raise TypeError
31 except TypeError:
32 tb = sys.exc_info()[2]
33 TracebackType = type(tb)
34 FrameType = type(tb.tb_frame)
35 tb = None; del tb
37 # For Jython, the following two types are identical
38 GetSetDescriptorType = type(FunctionType.__code__)
39 MemberDescriptorType = type(FunctionType.__globals__)
41 del sys, _f, _g, _C, # Not for export