Re: printing bytes to stdout in Py3

2009-02-17 Thread Scott David Daniels
Casey wrote: ... Is this the 'official' way to do this?... Why wouldn't you just use: print(bytes.decode(b'abc\n'), end='') Because that code is incapable of sending bytes that cannot be interpreted as encoded in the "default" encoding. If you are sending a picture, for example, all possible

Re: printing bytes to stdout in Py3

2009-02-17 Thread Christian Heimes
Casey schrieb: > On Feb 17, 12:33 pm, Christian Heimes wrote: >> Yes, it's really the official way. You can google up the discussion >> between me and Guido on the python-dev list if you don't trust me. ;) >> The docs concur with me, too. >> >> http://docs.python.org/3.0/library/sys.html#sys.stdin

Re: printing bytes to stdout in Py3

2009-02-17 Thread Casey
On Feb 17, 12:33 pm, Christian Heimes wrote: > Yes, it's really the official way. You can google up the discussion > between me and Guido on the python-dev list if you don't trust me. ;) > The docs concur with me, too. > > http://docs.python.org/3.0/library/sys.html#sys.stdin > > Note: The standar

Re: printing bytes to stdout in Py3

2009-02-17 Thread Christian Heimes
Casey wrote: > Is this really the 'official' way to do this? This isn't meant to be > confrontational or trolling; I honestly don't know the answer and I > had similar questions when I first started with the 3.0 release > candidates and I have yet to find a good answer in the Python v3.0 > documen

Re: printing bytes to stdout in Py3

2009-02-17 Thread Peter Billam
On 2009-02-17, Christian Heimes wrote: > Peter Billam schrieb: >> Greetings. (Newbie warning as usual) In Python3, sys.stdout is a >> io.TextIOWrapper object; but I want to output bytes >> (e.g. muscript -midi t > t.mid ) >> and they're coming out stringified :-( How can I either change the >>

Re: printing bytes to stdout in Py3

2009-02-17 Thread Casey
On Feb 17, 7:28 am, Christian Heimes wrote: > Peter Billam schrieb: > > > Greetings. (Newbie warning as usual) In Python3, sys.stdout is a > > io.TextIOWrapper object; but I want to output bytes > >   (e.g. muscript -midi t > t.mid ) > > and they're coming out stringified :-(  How can I either cha

Re: printing bytes to stdout in Py3

2009-02-17 Thread Christian Heimes
Peter Billam schrieb: > Greetings. (Newbie warning as usual) In Python3, sys.stdout is a > io.TextIOWrapper object; but I want to output bytes > (e.g. muscript -midi t > t.mid ) > and they're coming out stringified :-( How can I either change the > encoding on sys.stdout, or close sys.stdout and

Re: printing bytes to stdout in Py3

2009-02-17 Thread Gabriel Genellina
En Tue, 17 Feb 2009 03:04:23 -0200, Peter Billam escribió: Greetings. (Newbie warning as usual) In Python3, sys.stdout is a io.TextIOWrapper object; but I want to output bytes (e.g. muscript -midi t > t.mid ) and they're coming out stringified :-( How can I either change the encoding on sy

printing bytes to stdout in Py3

2009-02-16 Thread Peter Billam
Greetings. (Newbie warning as usual) In Python3, sys.stdout is a io.TextIOWrapper object; but I want to output bytes (e.g. muscript -midi t > t.mid ) and they're coming out stringified :-( How can I either change the encoding on sys.stdout, or close sys.stdout and reopen it in 'b' mode, or dup(f