Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; '21,': 0.07; 'cc:addr:python-list': 0.11; 'windows': 0.15; 'command- line': 0.16; 'descriptor': 0.16; 'descriptor.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'idle.': 0.16; 'itself,': 0.16; 'reedy': 0.16; 'replaced.': 0.16; 'stdout': 0.16; 'sure.': 0.16; 'sys.stdout': 0.16; 'unix,': 0.16; 'wrote:': 0.18; 'not,': 0.20; 'written': 0.21; '>>>': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'fine': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; '>>>>': 0.31; 'file': 0.32; '(most': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'idle': 0.36; 'pm,': 0.38; 'recent': 0.39; 'bad': 0.39; 'skip:o 30': 0.61; 'different': 0.65; 'subject:Hello': 0.72; 'available:': 0.91; 'subject:World': 0.91; 'to:none': 0.92 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:cc :content-type; bh=8nLQcC9lI91Le00EgHGpa73X6/PFTQxPangUXCcBDGY=; b=bi67prkOi0RA1LYKqlcrgRHMIbWQIyW6qNyQdCcy+cqda4WtwaI5CNPcPu1VZbcUhF ArFGxUbyyZmRgVIlnurxJW+Zfwfphj0NjX6IM0GY3DL9OGjyUP0mwdaR1zlQlwbbK1XU MN6QPFwdkXEOneLS69+KZ8ODoSgpiZxh7tr2ARN2Qr+ECow19RrCDVrW5PwTj9/9EPq9 NsbKmXosdi+6W/ReqVY/06fpfQhrta+wJzy0FeNip3qGJSc8ulPmkYGHs1NodNOquxNR 5SKH+/0UoE3AP0+RV0SkM2/DVvpyltzRy1T4f20p2vybWg/r04/yPTqdrRPGP5A7FGy6 M7CA== MIME-Version: 1.0 X-Received: by 10.50.171.168 with SMTP id av8mr10945032igc.2.1419144280915; Sat, 20 Dec 2014 22:44:40 -0800 (PST) In-Reply-To: References: <54957226$0$12975$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 21 Dec 2014 17:44:40 +1100 Subject: Re: Hello World From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1419144290 news.xs4all.nl 2972 [2001:888:2000:d::a6]:37978 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82711 On Sun, Dec 21, 2014 at 5:31 PM, Terry Reedy wrote: > Just to be clear, writing to sys.stdout works fine in Idle. >>>> import sys; sys.stdout.write('hello ') > hello #2.7 > > In 3.4, the number of chars? bytes? is returned and written also. > > Whether you mean something different by 'stdout' or not, I am not sure. The > error is from writing to a non-existent file descriptor. That's because sys.stdout is replaced. But stdout itself, file descriptor 1, is not available: >>> os.fdopen(1,"w").write("Hello, world\n") Traceback (most recent call last): File "", line 1, in os.fdopen(1,"w").write("Hello, world\n") OSError: [Errno 9] Bad file descriptor This works fine in command-line Python, just not in IDLE. It's not Windows vs Unix, it's Idle vs terminal. ChrisA