In python 2.x potrei fare questo:
import sys, array
a = array.array('B', range(100))
a.tofile(sys.stdout)
Ora, tuttavia, ottengo un TypeError: can't write bytes to text stream. C'è qualche codifica segreta che dovrei usare?
os.writefunzionerà sia su Py2 che su Py3.