Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21358

Re: sys.stdout.detach() results in ValueError

Date 2012-03-07 17:14 -0500
From Dave Angel <d@davea.name>
Subject Re: sys.stdout.detach() results in ValueError
References <alpine.DEB.2.00.1203072032590.2657@pebbe>
Newsgroups comp.lang.python
Message-ID <mailman.494.1331158511.3037.python-list@python.org> (permalink)

Show all headers | View raw


On 03/07/2012 02:41 PM, Peter Kleiweg wrote:
> I want to write out some binary data to stdout in Python3. I
> thought the way to do this was to call detach on sys.stdout. But
> apparently, you can't. Here is a minimal script:
>
>      #!/usr/bin/env python3.1
>      import sys
>      fp = sys.stdout.detach()
>
> Not yet using fp in any way, this script gives the following error:
>
>      Exception ValueError: 'underlying buffer has been detached' in
>
> Same in Python 3.1.4 and Python 3.2.2
>
> So, what do I do if I want to send binary data to stdout?
>
>
>

sys.stdout.write(  some_binary_data )

Why should you need to do some funny manipulation?

If you have some other unstated motivation, better ask a clearer question.



-- 

DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

sys.stdout.detach() results in ValueError Peter Kleiweg <pkleiweg@xs4all.nl> - 2012-03-07 20:41 +0100
  Re: sys.stdout.detach() results in ValueError Dave Angel <d@davea.name> - 2012-03-07 17:14 -0500
    Re: sys.stdout.detach() results in ValueError Peter Kleiweg <pkleiweg@xs4all.nl> - 2012-03-07 23:35 +0100
      Re: sys.stdout.detach() results in ValueError Terry Reedy <tjreedy@udel.edu> - 2012-03-07 19:10 -0500
        Re: sys.stdout.detach() results in ValueError Mark Tolonen <metolone@gmail.com> - 2012-03-07 16:41 -0800
  Re: sys.stdout.detach() results in ValueError Benjamin Peterson <benjamin@python.org> - 2012-03-08 03:49 +0000

csiph-web