backport_collections
backport_collections is a backport of Python 2.7's collections
module for Python 2.6.
What is backported?
Counter
, deque
, OrderedDict
and namedtuple
are backported.
The rest of the members of the collections
module are still exposed. Note
though that some ABC
classes are slighlty different (see known issues below).
Usage
To use it just import the desired classes from the module backport_collections
.
Example:
from backport_collections import Counter from backport_collections import deque from backport_collections import OrderedDict from backport_collections import namedtuple
Testing
To run the tests, you need to install unittest2
and nose
. Then run:
nosetests
The tests depend on Python's own test suite, which is not always
installed by default. In particular, Red Hat packages it separately as
python-test
, so you might need to run
sudo yum install python-test
first.
Known Issues
- In Python 2.6 Issue 9137 is not fixed as it complains if it gets a keyword
argument named
self
. The error isTypeError: update() got multiple values for keyword argument 'self'
. Additionally the keyword argument cannot be calledother
either as it will think it is the full dict. No error is raised in this case. - In Python 2.6 Issue 8743 is not fully fixed: Set interoperability with real sets
License
The Python Software Foundation License.
Changes
- v0.1 (15/08/2014): Synced to revision http://hg.python.org/cpython/rev/6d41f139709b