The difference between Ipython and Python

Source: Internet
Author: User

http://mba.shengwushibie.com/itbook/BookChapter.asp?id=8745http://www.cnblogs.com/yangze/archive/2011/07/11/2103040.htmlhttp://matrix.42qu.com/10735149http://www.cnblogs.com/weishun/p/great-ipython.htmlhttp://blog.sina.com.cn/s/blog_6fb8aa0d0101r5o1.html Ipython's developers have absorbed the basic concepts of the standard interpreter, and have made a lot of improvements on that basis, creating an amazing tool. On its homepage, it says, "This is an enhanced interactive python shell." "With tab completion, object introspection, powerful historical mechanisms, embedded source code editing, integrated Python debugger,%run mechanism, macros, creation of multiple environments, and the ability to invoke the system shell.1) The biggest difference between Ipython and standard Python is that Ipython will number each line of the command prompt. such as:


comparing two examples, the output variable values appear to be the same, but there are still differences. The print statement uses an informal (unofficial) string expression, while the simple variable name (bare variable name) uses a formal (official) string expression. This difference is evident when you are working with custom classes instead of built-in classes. In [ten]: Class Doublerep (object):....: def __str__ (self):....: Return ' Hi, I ' m a __str__ '....: def __repr__ (self):....: Return ' Hi, I ' m a __repr__ '....:  ....:  In [all]: Dr = Doublerep ()In []: Print DrHi, I ' m a __str__In [+]: Drout[13]: Hi, I ' m a __repr__2)tab Completion as an example, we first introduce the SYS module and then enter Sys. (Note that there is a point), when you press the TAB key, IPython lists the methods and properties under all SYS modules. then the above example, we enter the SYS, and then enter, this will show the SYS module docstring and related information. Most of the time this is also very convenient function.

3)Historical mechanismshist can quickly view the history of those inputs. Hist-n can quickly view and remove the sequence numbers from the history so that you can easily copy the code into a text editor. A simpler approach is to edit the slice (slice) syntax of the Python list:edit 4:7 to export the 4,5,6,7 sentence code to the editor 4)Breakpoint Debugging: If your program is executed by the command line, enter Python foo.py at the command line (most Python programs are), then you can also use IPython to debug breakpoints anywhere in your program. Anywhere in your program, add the following statement:From Ipython.shell import ipshellembedipshellembed ([]) ()Note: Recently IPython released the 0.11 release, the changes are very large, the API has been redesigned. If you are using 0.11 then the above two lines correspond to this:From IPython Import embedembed ()run your program as usual, and you'll find that when the program runs into the INSERT statement, it goes to the IPython environment. You can try running some instructions, and you'll find that the IPython environment is in that position of the program at the moment. You can navigate through each variable in the current state, invoke various functions, and output the values you are interested in to help with debugging. You can then exit IPython as usual, and the program will continue to run, and naturally the statements you execute at the time of IPython will have an impact on the next run of the program. This method is here (http://lukeplant.me.uk/blog/posts/exploratory-programming-with-ipython/) to see. Imagine doing this like getting a high-speed program to pause, and then checking and modifying the running program before letting him run. Here's an example, for example, to write a Web bot, you have to look at the contents of each page after you retrieve it, and then try to handle the address of the next page. Using this technique, you can break the program after retrieving the page, then experiment with the various processing methods, and then write back to your code after you find the correct treatment, then proceed to the next step. This workflow can only be done with a dynamic language like Python.

The difference between Ipython and Python

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.