- Created Wednesday, December 17th 2014 @ 07:51:07
How do i show data i want to show when my bot runs for myself in python?
i tried using print but that didnt do anything, i tried using stdout, but that seems to get tricky when im trying to output some data to view myself from a function in a seperate page
any help really appreciated, thank you :)
- Created Wednesday, December 17th 2014 @ 10:28:31
The server records both stdout and stderr. stdout is used to communicate your bot's actions to the server, and stderr is logged so you can review it and use it for debugging.
I've never used stderr in my Python coding (my bot is in C#, I have Console.Error.WriteLine() all over), but the first Google result for 'python stderr' is a stack overflow post with multiple ways to output to stderr.
- Updated Thursday, May 28th 2015 @ 15:09:43
from sys import stderr
def write_to_stderr( message_string ):
. . sys.stderr.write( message_string )
. . sys.stderr.flush()
. . return
# Usage example
write_this = "This sentence string will be output to stderr and you can see it in the match dump."
write_to_stderr( write_this )
The trick is to call the method flush() so the bytes being held in stderr's buffer actually get sent to the server and not just stay on the program's stack.