Python Sending command
<p>I'm trying to send a End command to the end of this line of code.
I've searched everywhere and not able to find a valuable answer..</p>

<pre><code>if args.time:
    def stopwatch(seconds):
        start = time.time()
        time.clock()    
        elapsed = 0
        while elapsed &lt; seconds:
            elapsed = time.time() - start
            print "Sending for(900) Seconds: %f, seconds count: %02d" % (time.clock() , elapsed) 
            time.sleep(1)  

stopwatch(5)
</code></pre>

<p>Wanting to send a <code>Control C</code> of some sort here to stop it without 
Exiting the program.</p>

<p>You want to catch a <code>KeyboardInterrupt</code>:</p>

<pre><code>if args.time:
    def stopwatch(seconds):
        start = time.time()
        time.clock()    
        elapsed = 0
        while elapsed &lt; seconds:
            try:
                elapsed = time.time() - start
                print "Sending for(900) Seconds: %f, seconds count: %02d" % (time.clock() , elapsed) 
                time.sleep(1)  
            except KeyboardInterrupt: break

    stopwatch(5)
</code></pre>

python