The problem is Python output buffering. Put sys.stdout.flush() after each print statement to ensure that the output is flushed to the output stream immediately, so you can see it then. The show command always flushes immediately, which is why it appears before.