Types missing from "types"module

J

John Nagle

Here's dir(types), in Python 2.6.5:

['BooleanType', 'BufferType', 'BuiltinFunctionType',
'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType',
'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType',
'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType',
'GetSetDescriptorType', 'InstanceType', 'IntType', 'LambdaType',
'ListType', 'LongType', 'MemberDescriptorType', 'MethodType',
'ModuleType', 'NoneType','NotImplementedType', 'ObjectType',
'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType',
'TypeType', 'UnboundMethodType', 'UnicodeType', 'XRangeType',
'__builtins__', '__doc__', '__file__', '__name__', '__package__']

Seems to be missing SetType, FrozenSetType, BytesType, and
ByteArrayType. Anything else missing?

(Arguably, "bytes" isn't really distinguished until 3.x, but
still...)

John Nagle
 
S

Stephen Hansen

Here's dir(types), in Python 2.6.5:

['BooleanType', 'BufferType', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType', 'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType', 'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType', 'GetSetDescriptorType', 'InstanceType', 'IntType', 'LambdaType', 'ListType', 'LongType', 'MemberDescriptorType', 'MethodType', 'ModuleType', 'NoneType','NotImplementedType', 'ObjectType', 'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType', 'TypeType', 'UnboundMethodType', 'UnicodeType', 'XRangeType', '__builtins__', '__doc__', '__file__', '__name__', '__package__']

Seems to be missing SetType, FrozenSetType, BytesType, and
ByteArrayType. Anything else missing?

(Arguably, "bytes" isn't really distinguished until 3.x, but
still...)

IIUC, since Python 2.2ish you can't treat the types module as
comprehensive. It exists as a remnant from the time when there was a
difference between types and classes.

Sets and the recent additions exist solely in this new world where we
just isinstance(blah, set) or issubclass or whatnot.

--Stephen via iPad
 
J

John Nagle

Here's dir(types), in Python 2.6.5:

['BooleanType', 'BufferType', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType', 'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType', 'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType', 'GetSetDescriptorType', 'InstanceType', 'IntType', 'LambdaType', 'ListType', 'LongType', 'MemberDescriptorType', 'MethodType', 'ModuleType', 'NoneType','NotImplementedType', 'ObjectType', 'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType', 'TypeType', 'UnboundMethodType', 'UnicodeType', 'XRangeType', '__builtins__', '__doc__', '__file__', '__name__', '__package__']

Seems to be missing SetType, FrozenSetType, BytesType, and
ByteArrayType. Anything else missing?

(Arguably, "bytes" isn't really distinguished until 3.x, but
still...)

IIUC, since Python 2.2ish you can't treat the types module as
comprehensive. It exists as a remnant from the time when there was a
difference between types and classes.

Sets and the recent additions exist solely in this new world where we
just isinstance(blah, set) or issubclass or whatnot.

Ah. That makes sense.

Does the "types" module go away in 3.x, then?

John Nagle
 
T

Thomas Jollans

Here's dir(types), in Python 2.6.5:

['BooleanType', 'BufferType', 'BuiltinFunctionType',
'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType',
'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType',
'FileType', 'FloatType', 'FrameType', 'FunctionType',
'GeneratorType', 'GetSetDescriptorType', 'InstanceType', 'IntType',
'LambdaType', 'ListType', 'LongType', 'MemberDescriptorType',
'MethodType', 'ModuleType', 'NoneType','NotImplementedType',
'ObjectType', 'SliceType', 'StringType', 'StringTypes',
'TracebackType', 'TupleType', 'TypeType', 'UnboundMethodType',
'UnicodeType', 'XRangeType', '__builtins__', '__doc__', '__file__',
'__name__', '__package__']

Seems to be missing SetType, FrozenSetType, BytesType, and
ByteArrayType. Anything else missing?

(Arguably, "bytes" isn't really distinguished until 3.x, but
still...)

IIUC, since Python 2.2ish you can't treat the types module as
comprehensive. It exists as a remnant from the time when there was a
difference between types and classes.

Sets and the recent additions exist solely in this new world where we
just isinstance(blah, set) or issubclass or whatnot.

Ah. That makes sense.

Does the "types" module go away in 3.x, then?

No, because while types like dict, int, and tuple are part of the core
language, other types aren't directly accessible.
['BuiltinFunctionType', 'BuiltinMethodType', 'CodeType', 'FrameType',
'FunctionType', 'GeneratorType', 'GetSetDescriptorType', 'LambdaType',
'MemberDescriptorType', 'MethodType', 'ModuleType', 'TracebackType',
'__builtins__', '__doc__', '__file__', '__name__', '__package__']
 
T

Terry Reedy

Does the "types" module go away in 3.x, then?

No, but all the duplication (IntType is int, etc) is removed.
['BuiltinFunctionType', 'BuiltinMethodType', 'CodeType', 'FrameType',
'FunctionType', 'GeneratorType', 'GetSetDescriptorType', 'LambdaType',
'MemberDescriptorType', 'MethodType', 'ModuleType', 'TracebackType',
'__builtins__', '__doc__', '__file__', '__name__', '__package__']
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top