Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Types missing from "types"module

Reply
Thread Tools

Types missing from "types"module

 
 
John Nagle
Guest
Posts: n/a
 
      06-24-2010
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
 
Reply With Quote
 
 
 
 
Stephen Hansen
Guest
Posts: n/a
 
      06-24-2010
Sent from my iPad

On Jun 23, 2010, at 9:24 PM, John Nagle <(E-Mail Removed)> wrote:

> 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
> --
> http://mail.python.org/mailman/listinfo/python-list

 
Reply With Quote
 
 
 
 
Stephen Hansen
Guest
Posts: n/a
 
      06-24-2010
On Jun 23, 2010, at 9:24 PM, John Nagle <(E-Mail Removed)> wrote:

> 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
 
Reply With Quote
 
John Nagle
Guest
Posts: n/a
 
      06-24-2010
On 6/23/2010 10:08 PM, Stephen Hansen wrote:
> On Jun 23, 2010, at 9:24 PM, John Nagle<(E-Mail Removed)> wrote:
>
>> 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
 
Reply With Quote
 
Ian Kelly
Guest
Posts: n/a
 
      06-24-2010
On Thu, Jun 24, 2010 at 12:29 AM, John Nagle <(E-Mail Removed)> wrote:
> * Does the "types" module go away in 3.x, then?


Not entirely, but it is greatly reduced.
 
Reply With Quote
 
Thomas Jollans
Guest
Posts: n/a
 
      06-24-2010
On 06/24/2010 08:29 AM, John Nagle wrote:
> On 6/23/2010 10:08 PM, Stephen Hansen wrote:
>> On Jun 23, 2010, at 9:24 PM, John Nagle<(E-Mail Removed)> wrote:
>>
>>> 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.

>>> import types
>>> dir(types)

['BuiltinFunctionType', 'BuiltinMethodType', 'CodeType', 'FrameType',
'FunctionType', 'GeneratorType', 'GetSetDescriptorType', 'LambdaType',
'MemberDescriptorType', 'MethodType', 'ModuleType', 'TracebackType',
'__builtins__', '__doc__', '__file__', '__name__', '__package__']
>>>



 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      06-24-2010
On 6/24/2010 2:29 AM, John Nagle wrote:

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


No, but all the duplication (IntType is int, etc) is removed.

>>> dir(types)

['BuiltinFunctionType', 'BuiltinMethodType', 'CodeType', 'FrameType',
'FunctionType', 'GeneratorType', 'GetSetDescriptorType', 'LambdaType',
'MemberDescriptorType', 'MethodType', 'ModuleType', 'TracebackType',
'__builtins__', '__doc__', '__file__', '__name__', '__package__']
--
Terry Jan Reedy

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can XSD simple types be derived from complex types? Soren Kuula XML 2 12-01-2005 07:51 PM
Where are ref types that are members of value types stored? Sathyaish ASP .Net 2 05-22-2005 07:32 PM
missing types in module types? Manlio Perillo Python 0 05-29-2004 06:33 AM
Boost + Python C/API: Mixing python return types with boost return types Steve Knight Python 2 10-10-2003 10:11 AM
STD types vs C++ intrinsic types Jeremy Cowles C++ 5 08-19-2003 05:33 PM



Advertisments