running python 2 vs 3

Zachary Ware zachary.ware+pylist at gmail.com
Thu Mar 20 16:43:50 EDT 2014


On Thu, Mar 20, 2014 at 3:30 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> I must say, though, that Python3 destroyed "print" forever for me. To
> avoid nausea, I write sys.stdout.write() in all Python3 code.

To each their own :).  I can't stand using 'print' as a statement.
It's a very nice trick to be able to write a script, think "oh, all
those prints should really be sending that output somewhere else", and
then instead of changing every individual print, just define a
different 'print' function at the top of the file (which may be as
simple as `print = functools.partial(print, file=sys.stderr)` or
`print = logging.debug`).

-- 
Zach



More information about the Python-list mailing list