Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string.': 0.05; 'subject:data': 0.07; 'subject:string': 0.09; 'python': 0.11; 'sat,': 0.13; 'bytes,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'linux).': 0.16; 'stdin': 0.16; 'stream.': 0.16; 'subject:changing': 0.16; 'string': 0.18; 'received:209.85.210.174': 0.20; 'received:mail- iy0-f174.google.com': 0.20; 'wrote:': 0.21; 'string,': 0.22; 'header:In-Reply-To:1': 0.22; '(which': 0.24; 'input': 0.24; 'message-id:@mail.gmail.com': 0.27; 'python3': 0.29; 'file': 0.29; 'received:209.85': 0.32; 'received:209.85.210': 0.32; 'gets': 0.32; 'received:google.com': 0.32; 'guess': 0.32; 'subject: (': 0.33; 'byte': 0.33; 'encoding': 0.33; 'explicitly': 0.33; 'in.': 0.33; 'mode': 0.33; 'skip:s 20': 0.34; 'reading': 0.34; 'received:209': 0.35; 'subject:)': 0.36; 'text': 0.36; 'but': 0.36; 'too.': 0.37; 'skip:" 10': 0.38; 'to:addr:python-list': 0.39; 'to:addr:python.org': 0.40; 'mar': 0.61; 'opened': 0.66; 'believe': 0.67; '2012': 0.69; 'skip:\xd0 20': 0.72 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=BFW1lqUdonjSEBJAzOfHsdEnfvj+J77inQFPKUO3DDU=; b=a1F3P/ZadmgoUJD4S5Js7Zb0oQI93bOxdq4QiVtqwuP0jqeJu6WjGPtMTpJGkNFQpZ qkaHJFmU5cAoEADKjKxngSEPj+u1lO/X42LYfwvVjW2bxJXCSzWpyet65NjLLzHvesDo hTuK6WW7j0yJTNSTZMbs6ZQomFej7f+jzHiadiUqpjOUt0jvlX+/9lmzM9iB+X8tG2gZ GEPBVsjSzqPFd+zMnYjxjOWxN6/+/CdpTFeTkyLaSW+GrDyT8OiUW3LJuLSQLyu9439k PcFg6q05PbBsNeUGKOD1fb0rbuQw8YFpp9sw6B7T8qU8+KpHcgLKj8LqgJXsnfZx2GML Vh7Q== MIME-Version: 1.0 In-Reply-To: References: <9tg21lFmo3U1@mid.dfncis.de> <9tg4qoFbfpU1@mid.dfncis.de> <9th0u8Fuf2U1@mid.dfncis.de> <1053a4e195cf2e85778f6c2c63dc89d4@modelnine.org> Date: Sat, 31 Mar 2012 06:10:03 +1100 Subject: Re: "convert" string to bytes without changing data (encoding) From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1333134606 news.xs4all.nl 6969 [2001:888:2000:d::a6]:33722 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22391 On Sat, Mar 31, 2012 at 6:06 AM, Serhiy Storchaka wro= te: > 28.03.12 21:13, Heiko Wundram =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=B2(= =D0=BB=D0=B0): > >> Reading from stdin/a file gets you bytes, and >> not a string, because Python cannot automagically guess what format the >> input is in. > > > In Python3 reading from stdin gets you string. Use sys.stdin.buffer.raw f= or > access to byte stream. And reading from file opened in text mode gets you > string too. True. But that's only if it's been told the encoding of stdin (which I believe is the normal case on Linux). It's still not "automagically guess(ing)", it's explicitly told. ChrisA