[Pythonmac-SIG] MacPython IDE 1.0.1 -- Is this a bug?

Steven Majewski sdm7g@Virginia.EDU
Mon, 18 Mar 2002 19:18:21 -0500 (EST)


On Mon, 18 Mar 2002, Bruce Robbins wrote:

> Try running this AS A SCRIPT in the MacPython IDE v.1.0.1:
>
> list = [33, 44, 55, 66]
>
> for each in list:
>   print each,
>
>
> Make sure you include the comma after the print each statement.
> Then try it without the comma.
>
> No output in the output window when run with the comma -- until
> the script is run again without the comma!
>

  If you append either:


print

  or

import sys; sys.stdout.flush()


  after your two lines above, you'll get the output. (The first with a
  trailing newline, the latter without.)

  I'm guessing that sys.stdout.close() would also work, but wouldn't
  be very useful to you.

  That should make the reason for the behaviour obvious.
  ( You don't get it in the interpreter window, because the line gets
    flushed when it prints out a '>>>' prompt for the next input line.)

  Is it a bug?
  I'ld vote no -- it matches exactly what would happen if you had a
  script writing to a file, or executed a script on the unix command line
  (so you wouldn't get any prompts to the terminal) except that sys.stdout
  would get flushed and closed at program termination.


-- Steve Majewski