Chris, On Saturday, 2019-12-21 06:45:24 +1100, you wrote: > ... > This construct can be simplified down to: > > stdout = getattr(sys.stdout, "buffer", sys.stdout) Nice! And with my admittedly trivial test case it correctly works under both, Python 2 and Python 3. Now I'll do some more serious testing ... Sincerely, Rainer