我正在通过命令行在Amazon EC2实例上编写一些Python代码。
我正在尝试调试此事。但是,当我在调试器中运行restart
或run
时,会收到此长错误消息。我在ipdb或pdb中得到它。
ipdb> run
---------------------------------------------------------------------------
Restart Traceback (most recent call last)
<ipython-input-2-58ca95c5b364> in <module>()
----> 1 main()
/home/ubuntu/112euler.py in main()
42 x = error(t, b)
43 while abs(x - 0.99) > 1e-4:
---> 44 if bouncy(n) == True:
45 t += 1
46 b += 1
/home/ubuntu/112euler.py in main()
42 x = error(t, b)
43 while abs(x - 0.99) > 1e-4:
---> 44 if bouncy(n) == True:
45 t += 1
46 b += 1
/usr/lib/python2.7/bdb.pyc in trace_dispatch(self, frame, event, arg)
46 return # None
47 if event == 'line':
---> 48 return self.dispatch_line(frame)
49 if event == 'call':
50 return self.dispatch_call(frame, arg)
/usr/lib/python2.7/bdb.pyc in dispatch_line(self, frame)
64 def dispatch_line(self, frame):
65 if self.stop_here(frame) or self.break_here(frame):
---> 66 self.user_line(frame)
67 if self.quitting: raise BdbQuit
68 return self.trace_dispatch
/usr/lib/python2.7/pdb.pyc in user_line(self, frame)
156 self._wait_for_mainpyfile = 0
157 if self.bp_commands(frame):
--> 158 self.interaction(frame, None)
159
160 def bp_commands(self,frame):
/usr/local/lib/python2.7/dist-packages/ipython-0.13- py2.7.egg/IPython/core/debugger.pyc in interaction(self, frame, traceback)
249 def interaction(self, frame, traceback):
250 self.shell.set_completer_frame(frame)
--> 251 OldPdb.interaction(self, frame, traceback)
252
253 def new_do_up(self, arg):
/usr/lib/python2.7/pdb.pyc in interaction(self, frame, traceback)
208 self.setup(frame, traceback)
209 self.print_stack_entry(self.stack[self.curindex])
--> 210 self.cmdloop()
211 self.forget()
212
/usr/lib/python2.7/cmd.pyc in cmdloop(self, intro)
140 line = line.rstrip('\r\n')
141 line = self.precmd(line)
--> 142 stop = self.onecmd(line)
143 stop = self.postcmd(stop, line)
144 self.postloop()
/usr/lib/python2.7/pdb.pyc in onecmd(self, line)
277 """
278 if not self.commands_defining:
--> 279 return cmd.Cmd.onecmd(self, line)
280 else:
281 return self.handle_command_def(line)
/usr/lib/python2.7/cmd.pyc in onecmd(self, line)
219 except AttributeError:
220 return self.default(line)
--> 221 return func(arg)
222
223 def emptyline(self):
/usr/lib/python2.7/pdb.pyc in do_run(self, arg)
677 sys.argv = shlex.split(arg)
678 sys.argv[:0] = argv0
--> 679 raise Restart
680
681 do_restart = do_run
Restart:
编辑:我正在尝试运行以下代码。这是项目欧拉#112。除main()
之外的所有功能都有效; main()
陷入无限循环中我很确定。这就是我使用调试器的原因!
def main():
t = 0.0; b =0
n = 100
x = error(t, b)
# pdb.set_trace()
while abs(x - 0.99) >1e-1:
#if n == 21780:
# pdb.set_trace()
if bouncy(n) == True:
t += 1
b += 1
else:
b += 1
n += 1
print n, t, b