Types missing from "types"module

Discussion in 'Python' started by John Nagle, Jun 24, 2010.

  1. John Nagle

    John Nagle Guest

    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
     
    John Nagle, Jun 24, 2010
    #1
    1. Advertisements

  2. Sent from my iPad
     
    Stephen Hansen, Jun 24, 2010
    #2
    1. Advertisements

  3. 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
     
    Stephen Hansen, Jun 24, 2010
    #3
  4. John Nagle

    John Nagle Guest

    Ah. That makes sense.

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

    John Nagle
     
    John Nagle, Jun 24, 2010
    #4
  5. John Nagle

    Ian Kelly Guest

    Not entirely, but it is greatly reduced.
     
    Ian Kelly, Jun 24, 2010
    #5
  6. 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__']
     
    Thomas Jollans, Jun 24, 2010
    #6
  7. John Nagle

    Terry Reedy Guest

    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__']
     
    Terry Reedy, Jun 24, 2010
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.