Hi all,
    I'm a new Python programmer and just picked up Abe Fettig's "Twisted" book. I tried out the first example, which use reactor.run() to drive printTime and stopReactor callback functions to print time, and found some strange things.

   I wrote the code in a .py file and run it, it's fine. However, when I tried to write the code in interactive mode and run it from IDLE shell window, all the four printTime were called at once. Why?

   Thank you in advance.

   The session is listed here:

>>> from twisted.internet import reactor
>>> import time
>>> def printTime():
    print "Current time is ", time.strftime("%H:%M:%S")

   
>>> def stopReactor():
    printTime()
        print "Stopping reactor"
        reactor.stop()

       
>>> reactor.callLater(1, printTime)
<twisted.internet.base.DelayedCall instance at 0x00D9E288>
>>> reactor.callLater(2, printTime)
<twisted.internet.base.DelayedCall instance at 0x00E42210>
>>> reactor.callLater(3, printTime)
<twisted.internet.base.DelayedCall instance at 0x00DF8BC0>
>>> reactor.callLater(4, printTime)
<twisted.internet.base.DelayedCall instance at 0x00C74760>
>>> reactor.callLater(5, stopReactor)
<twisted.internet.base.DelayedCall instance at 0x0132E738>
>>> reactor.run()
Current time is  09:06:52
Current time is  09:06:52
Current time is  09:06:52
Current time is  09:06:52
Current time is  09:06:52
Stopping reactor