Hi all,<br>&nbsp;&nbsp;&nbsp; I'm a new Python programmer and just picked up Abe Fettig's &quot;Twisted&quot; 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.
<br><br>&nbsp;&nbsp; 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? <br><br>&nbsp;&nbsp; Thank you in advance.
<br><br>&nbsp;&nbsp; The session is listed here:<br><br>&gt;&gt;&gt; from twisted.internet import reactor<br>&gt;&gt;&gt; import time<br>&gt;&gt;&gt; def printTime():<br>&nbsp;&nbsp;&nbsp; print &quot;Current time is &quot;, time.strftime(&quot;%H:%M:%S&quot;)
<br><br>&nbsp;&nbsp;&nbsp; <br>&gt;&gt;&gt; def stopReactor():<br>&nbsp;&nbsp;&nbsp; printTime()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Stopping reactor&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.stop()<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&gt;&gt;&gt; reactor.callLater(1, printTime)<br>&lt;twisted.internet.base.DelayedCall
 instance at 0x00D9E288&gt;<br>&gt;&gt;&gt; reactor.callLater(2, printTime)<br>&lt;twisted.internet.base.DelayedCall instance at 0x00E42210&gt;<br>&gt;&gt;&gt; reactor.callLater(3, printTime)<br>&lt;twisted.internet.base.DelayedCall
 instance at 0x00DF8BC0&gt;<br>&gt;&gt;&gt; reactor.callLater(4, printTime)<br>&lt;twisted.internet.base.DelayedCall instance at 0x00C74760&gt;<br>&gt;&gt;&gt; reactor.callLater(5, stopReactor)<br>&lt;twisted.internet.base.DelayedCall
 instance at 0x0132E738&gt;<br>&gt;&gt;&gt; reactor.run()<br>Current time is&nbsp; 09:06:52<br>Current time is&nbsp; 09:06:52<br>Current time is&nbsp; 09:06:52<br>Current time is&nbsp; 09:06:52<br>Current time is&nbsp; 09:06:52<br>Stopping reactor
<br><br><br>