2013-10-14 30 views

回答

3

在某些(大多數/所有?)實現OrderedDict是公共collections module的一部分,而不是內部_collections的。

我伸出你的片段,包括詳細信息:

import sys 
print(sys.version) 
import _collections as _cl 
print "_collections:", dir(_cl) 
import collections as cl 
print "collections:", dir(cl) 

對於IronPython的結果是:

2.7.4 (IronPython 2.7.4 (2.7.0.40) on .NET 4.0.30319.18331 (32-bit)) 
_collections: ['__doc__', '__name__', '__package__', 'defaultdict', 'deque'] 
collections: ['Callable', 'Container', 'Counter', 'Hashable', 'ItemsView', 'Iterable', 'Iterator', 'KeysView', 'Mapping', 'MappingView', 'MutableMapping', 'MutableSequence', 'MutableSet', 'OrderedDict', 'Sequence', 'Set', 'Sized', 'ValuesView', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_abcoll', '_chain', '_get_ident', '_heapq', '_iskeyword', '_itemgetter', '_repeat', '_starmap', '_sys', 'defaultdict', 'deque', 'namedtuple'] 

對於CPython的結果是:

2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] 
_collections: ['__doc__', '__name__', '__package__', 'defaultdict', 'deque'] 
collections: ['Callable', 'Container', 'Counter', 'Hashable', 'ItemsView', 'Iterable', 'Iterator', 'KeysView', 'Mapping', 'MappingView', 'MutableMapping', 'MutableSequence', 'MutableSet', 'OrderedDict', 'Sequence', 'Set', 'Sized', 'ValuesView', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_abcoll', '_chain', '_class_template', '_eq', '_field_template', '_get_ident', '_heapq', '_imap', '_iskeyword', '_itemgetter', '_repeat', '_repr_template', '_starmap', '_sys', 'defaultdict', 'deque', 'namedtuple']