Some Python I learned

While I was writing a simple stopwatch script in python I came across a few hurdles. If you print out a line and don't include the ending carriage return it buffers the output. Sometimes this isn't what you want, and you have to flush the output buffer.

sys.stdout.flush() I also needed to figure out how to capture ctrl+c in python. If you hit ctrl+c while a python script is running you get a bunch of debug messages. Not what I wanted. import signal signal.signal(signal.SIGINT, sig_handle) def sig_handle(signal,frame): print signal, "was handled!"


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.139.72.78
To prevent spam please submit by clicking the kitten: