Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'essentially': 0.04; 'subject:Python': 0.06; 'attribute': 0.07; 'binary': 0.07; 'sys': 0.07; 'bytes,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'strings.': 0.09; 'wrapped': 0.09; 'jan': 0.12; 'ought': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'stdout': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; '2.x': 0.24; 'bytes': 0.24; 'certainly': 0.24; 'text.': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'mode': 0.30; '(which': 0.31; 'gives': 0.31; '"",': 0.31; '3.x': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'file': 0.32; 'text': 0.33; 'url:python': 0.33; '(most': 0.33; 'convert': 0.35; 'but': 0.35; 'there': 0.35; 'words,': 0.36; "i'll": 0.36; 'url:org': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'pm,': 0.38; 'recent': 0.39; 'does': 0.39; 'received:71': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'users': 0.40; 'read': 0.60; 'easy': 0.60; 'url:3': 0.61; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Python 3 is killing Python Date: Wed, 16 Jul 2014 18:47:37 -0400 References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-71-175-90-87.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405550898 news.xs4all.nl 2886 [2001:888:2000:d::a6]:45388 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74593 On 7/16/2014 5:02 PM, Terry Reedy wrote: > On 7/16/2014 3:49 AM, Steven D'Aprano wrote: > >> There are certainly use-cases for stdin and stdout to use bytes, but >> there are also use-cases for them to deal with strings. I'll certainly >> grant you that there ought to be an easy way to get access to the binary >> streams, > > As has been discussed before on this list, there is in 3.x. > https://docs.python.org/3/library/sys.html#sys.stdin > > >>> b=sys.stdin.buffer.readline() > a line > >>> b > b'a line\r\n' > > In other words, 3.x text mode (which essentially nothing to do with 2.x > 'text' mode), is a wrapped binary mode that gives users the *choice* to > read bytes or text. One can also convert a stream permanently with .detach() >>> import sys >>> sys.stdin = sys.stdin.detach() >>> b = sys.stdin.readline() a line >>> b b'a line\r\n' This does diable the input() function ;-). >>> b = input() Traceback (most recent call last): File "", line 1, in AttributeError: '_io.BufferedReader' object has no attribute 'errors' -- Terry Jan Reedy