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


Groups > comp.lang.python > #21358

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

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'sys': 0.05; 'python': 0.08; 'valueerror:': 0.09; 'error:': 0.10; 'exception': 0.12; 'binary': 0.13; 'detach': 0.16; 'received:192.168.1.104': 0.16; 'stdout': 0.16; 'subject:() ': 0.16; 'cc:addr:python-list': 0.16; 'question.': 0.16; 'wrote:': 0.18; 'subject:skip:s 10': 0.18; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.26; 'import': 0.27; 'script': 0.28; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'yet': 0.32; 'header :User-Agent:1': 0.33; 'skip:# 10': 0.34; 'minimal': 0.37; 'but': 0.37; 'using': 0.37; 'received:192': 0.38; 'some': 0.38; 'should': 0.38; 'data': 0.38; 'received:192.168.1': 0.39; 'here': 0.64; 'header:Reply-To:1': 0.70; 'reply-to:no real name:2**0': 0.72; 'funny': 0.76; 'clearer': 0.84; 'stdout?': 0.84; 'sys.stdout.': 0.84
Date Wed, 07 Mar 2012 17:14:35 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.27) Gecko/20120216 Thunderbird/3.1.19
MIME-Version 1.0
To Peter Kleiweg <pkleiweg@xs4all.nl>
Subject Re: sys.stdout.detach() results in ValueError
References <alpine.DEB.2.00.1203072032590.2657@pebbe>
In-Reply-To <alpine.DEB.2.00.1203072032590.2657@pebbe>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:1yK1vDQ/INfKtLteQUdcTLcReTpX1ygXxauRcW/nNDh n0hjxWhqEp3qc74jNcpAuBkj0rGX4n4ZhDCa6GqUQjzDJ0YAY7 pKF+jmflaTxHwXsrr1e18Q9bvp5GVLcRd9lhZEjtQ9+QA8lG8P QSAjYa4xkOvgd1qVSgY1gbxDUTen4MyS2qRwLIbifFP6IazsLm FrS0xwExoDS0RB3+U4HmBqIt7OJRXSu9qGPWdOR9NNr2fYBnCa 9Y6jbvCkW8ODlT98RsqSoS3CFIvs4Nwb9oOGhxRN1MTAwRXeUT 5Y3mETWy+8OuClpz7CxvKyxln0mI8UYfvts5r4zpevmUQyPZQ= =
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To d@davea.name
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.494.1331158511.3037.python-list@python.org> (permalink)
Lines 32
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1331158511 news.xs4all.nl 6873 [2001:888:2000:d::a6]:33289
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21358

Show key headers only | 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