jaraco.compat /

Filename Size Date modified Message
33 B
362 B
1.6 KB
1.1 KB


jaraco.compat provides forward compatibility for Python packages, allowing future constructs to be borrowed before they're available in the standard library.


Import functions from the appropriate pyXXcompat module in your python code. When you're eventually ready to upgrade beyond pyXX, you can easily locate (with a grep) and replace those functions with the canonical implementations.


Say you want a namedtuple (introduced in Python 2.6) in a project which supports Python 2.5 and greater:

from py25compat import namedtuple
MyTuple = namedtuple('MyTuple', 'a b c')
mt = MyTuple(1,2,3)

With jaraco.compat installed, this code will run on Python 2.5 and greater. When the project is ready to move to Python 2.6, one can easily grep for py25compat and make the necessary replacements with minimal impact on the code. In this case:

from collections import namedtuple
MyTuple = namedtuple('MyTuple', 'a b c')
mt = MyTuple(1,2,3)



  • Added py25compat.subprocess with term_proc and kill_proc which take Popen objects and terminate and kill them respectively.


  • Added py31compat.functools, which provides wraps and update_wrapper that supply the Python 3.2 __wrapped__ attribute.
  • Added py26compat.collections, which provides OrderedDict on Python 2.6 and earlier (via the ordereddict package).


  • Added py26compat.total_seconds
  • Added py24compat.partition


  • Added py26compat with cmp_to_key.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.