Overview

A Python 2 and 3 compatible print function. Handles sep, end, and file arguments like like Python 3's print function.

Usage

from print23 import *

print23("Hello, world!")

print23('this', 'and', 'that', sep='|')  # this|and|that

It's not very sophistated or functional. If you want those things, have a look at my say module. This is the exact opposite--something drop-dead simple that works across Python 2 and 3 without running into any from __future__ import print_function nonsense (which causes programs to break when run under Python 3, aka "the future").

If you like, you can give it another name, such as:

from print23 import print23 as print_

print_(...)

or:

from print23 import print23 as _print

_print(...)

...just as long as the name you give it isn't print, which will cause problems.

Notes

  • The six cross-version compatibility module contains its own print-alike, six.print_(). If you're going to import the six module for other things, feel free to use that. I do!
  • Employs the wonderful pytest and tox modules for automated multi-version testing.
  • The author, Jonathan Eunice or @jeunice on Twitter welcomes your comments and suggestions.

Installation

pip install print23

To easy_install under a specific Python version (3.3 in this example):

python3.3 -m easy_install print23

(You may need to prefix these with "sudo " to authorize installation.)