mirror of
https://github.com/python/cpython.git
synced 2024-12-01 11:15:56 +01:00
1325790b93
svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55797 | neal.norwitz | 2007-06-07 00:00:57 -0700 (Thu, 07 Jun 2007) | 3 lines Get rid of some remnants of classic classes. types.ClassType == type. Also get rid of almost all uses of the types module and use the builtin name. ........ r55798 | neal.norwitz | 2007-06-07 00:12:36 -0700 (Thu, 07 Jun 2007) | 1 line Remove a use of types, verify commit hook works ........ r55809 | guido.van.rossum | 2007-06-07 11:11:29 -0700 (Thu, 07 Jun 2007) | 2 lines Fix syntax error introduced by Neal in last checkin. ........
78 lines
1.8 KiB
Python
78 lines
1.8 KiB
Python
"""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
|
|
|
|
# Iterators in Python aren't a matter of type but of protocol. A large
|
|
# and changing number of builtin types implement *some* flavor of
|
|
# iterator. Don't check the type! Use hasattr to check for both
|
|
# "__iter__" and "__next__" attributes instead.
|
|
|
|
NoneType = type(None)
|
|
TypeType = type
|
|
ObjectType = object
|
|
|
|
IntType = int
|
|
LongType = int
|
|
FloatType = float
|
|
BooleanType = bool
|
|
try:
|
|
ComplexType = complex
|
|
except NameError:
|
|
pass
|
|
|
|
BufferType = buffer
|
|
|
|
TupleType = tuple
|
|
ListType = list
|
|
DictType = DictionaryType = dict
|
|
|
|
def _f(): pass
|
|
FunctionType = type(_f)
|
|
LambdaType = type(lambda: None) # Same as FunctionType
|
|
CodeType = type(_f.__code__)
|
|
|
|
def _g():
|
|
yield 1
|
|
GeneratorType = type(_g())
|
|
|
|
class _C:
|
|
def _m(self): pass
|
|
ClassType = type
|
|
UnboundMethodType = type(_C._m) # Same as MethodType
|
|
MethodType = type(_C()._m)
|
|
|
|
BuiltinFunctionType = type(len)
|
|
BuiltinMethodType = type([].append) # Same as BuiltinFunctionType
|
|
|
|
ModuleType = type(sys)
|
|
|
|
try:
|
|
raise TypeError
|
|
except TypeError:
|
|
tb = sys.exc_info()[2]
|
|
TracebackType = type(tb)
|
|
FrameType = type(tb.tb_frame)
|
|
tb = None; del tb
|
|
|
|
SliceType = slice
|
|
EllipsisType = type(Ellipsis)
|
|
|
|
DictProxyType = type(TypeType.__dict__)
|
|
NotImplementedType = type(NotImplemented)
|
|
|
|
# Extension types defined in a C helper module. XXX There may be no
|
|
# equivalent in implementations other than CPython, so it seems better to
|
|
# leave them undefined then to set them to e.g. None.
|
|
try:
|
|
import _types
|
|
except ImportError:
|
|
pass
|
|
else:
|
|
GetSetDescriptorType = type(_types.Helper.getter)
|
|
MemberDescriptorType = type(_types.Helper.member)
|
|
del _types
|
|
|
|
del sys, _f, _g, _C, # Not for export
|