Efficient Python program debugging and Python program debugging

Source: Internet
Author: User

Efficient Python program debugging and Python program debugging

Now I can print the python program in debug for a while where possible errors occur. I wonder if python has one-step debugging tools like c ++'s IDE? Or how do python programmers debug their own python programs?

 

Should I have used IPython? Imagine how happy it is to automatically bring you to IPython Shell when an exception is thrown? In addition, unlike IPython, you can call commands such as p (print), up (up stack), and down (down stack. You can also create temporary variables and execute any function.

In fact, this can be implemented, and it is very simple, but you need to install IPython first. Save the following code as 'crash _ on_ipy.py'
Import sysclass ExceptionHook: instance = 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. export thook = ExceptionHook () # He asked hovertree.com

Then import crash_on_ipy somewhere in your project code.

This method does not require IDE.

Recommended: http://www.cnblogs.com/roucheng/p/pythonstring.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.