5

I'm using logging extensively in my program. But now I want to write to stdout without using the logging module, but the output does not show up.

Neither:

sys.stdout.write( "BOE!" )

Nor

print( "WAH!" )

is working. Can someone enlighten me?

6
  • Can you post a minimal test case? Commented Jun 21, 2013 at 18:58
  • Is this an application, you are running from console? I am new to python. However, if this is a windows based app, where will this get logged? Commented Jun 21, 2013 at 19:02
  • Well, that's the thing, in a minimal example it DOES work. So I'm just looking for people who have seen it before. The reason why I assume it's due to logging, is because I've seen it before myself, but only in applications that used logging + it occured only after I started using the logging module. Commented Jun 21, 2013 at 19:04
  • 1
    It really shouldn't be due to logging (provided that you use the default logging module). Make sure that you didn't change sys.stdout anywhere. Commented Jun 21, 2013 at 19:04
  • Yes it's a console application. In windows one would have to use a terminal emulator such as cygwin to use it. Commented Jun 21, 2013 at 19:05

1 Answer 1

7

Its possible that your Python output is being buffered. Have a look at these two StackOverflow QAs:

  1. Disable output buffering
  2. How to flush output of Python print?
Sign up to request clarification or add additional context in comments.

3 Comments

I should have mentioned that I've already tried flushing the stream
Additionally I've tried to use stderr, which is unbuffered if I'm not mistaken
Whoo, something went wrong when I tested that. It actually did the trick. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.