Now I'm in the Debug Python program just simply print it out in the wrong place, and don't know if Python has a single-step debugging tool like some C + + ides? Or how does the Python God debug his own Python program in general?
You should've used IPython, right? Imagine, would it be nice to automatically take you to the IPython Shell when throwing an exception? And unlike normal Ipython, this time you can call commands such as P (print), up stack, and down stack. You can also create temporary variables and execute arbitrary functions.
In fact, this is achievable and simple, but you need to install IPython first. Then save the following code as ' crash_on_ipy.py '
Import SYS class Exceptionhook: = None def __call__ (self, *args, **kwargs): if self.instance Is None: from IPython. Core Import ULTRATB self. Instance = ULTRATB. FORMATTEDTB (mode= ' Plain ', color_scheme= ' Linux ', call_pdb=1) return Self.instance (*args, * *kwargs) sys. Excepthook = Exceptionhook ()# why ask? Hovertree.com
You can then import crash_on_ipy somewhere in your project code.
This method does not require the IDE.
Recommendation: http://www.cnblogs.com/roucheng/p/pythonstring.html
The Python program is highly efficient to debug