redirect standard output problem

Chris Angelico rosuav at gmail.com
Sat Dec 22 16:15:01 CET 2012


On Sun, Dec 23, 2012 at 2:07 AM, iMath <redstone-cold at 163.com> wrote:
> when I run it through command line ,it works ok ,but when I run it through IDLE , only print A but leave out 888
> so why ?

Because IDLE has to fiddle with stdin/stdout a bit to function. Try
adopting Dave's recommendation - you'll likely find that it then
works.

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600
32 bit (Intel)] on win32
>>> sys.stdout is sys.__stdout__
True

The same in IDLE:
>>> sys.stdout is sys.__stdout__
False

Whenever you work in IDLE, expect that some things will be slightly
different, mostly to do with standard I/O streams. So when you post
issues that you've come across, please state that you're using IDLE -
it likely makes a difference!

ChrisA



More information about the Python-list mailing list