Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ The difference between IPython and Python     - Linux resource restriction level summary (Linux)

- Ubuntu Linux use MAC binding against ARP attacks (Linux)

- Git commands (Linux)

- Linux Proc File System Experiment (Linux)

- Why everybody ought to know LLVM (Linux)

- Ubuntu under VirtualBox virtual machine serial port settings (Linux)

- Difference Docker mirror and containers (Server)

- Deepin Tutorial: Depth Description Installer expert mode (Linux)

- PostgreSQL-- run Supervisord on Docker in Ubuntu (Database)

- Using IntelliJ IDEA Import Spark Spark latest source code and compile the source code (Linux)

- Vim configuration instructions (Linux)

- Java development specifications summary (Programming)

- Wildcards and special symbols usage comments under Linux (Linux)

- Open log in Hibernate (Programming)

- Samhain: Powerful intrusion detection system under Linux (Linux)

- Ubuntu Linux Change the PATH (Linux)

- C ++ Supplements - locates the new expression (Programming)

- Alternative methods of intrusion bundled executable file new thinking (Linux)

- Hadoop 0.23 compile common errors (Server)

- Python method to traverse folders and file read and write (Programming)

  The difference between IPython and Python
  Add Date : 2017-04-13      
  IPython developers to absorb the basic concept of the standard interpreter, on the basis of a lot of improvements, creating an amazing tool. On its home page says so:. "This is an enhanced interactive Python shell" has tab completion, object introspection, strong history mechanism, embedded in the source code editor, integrated Python debugger,% run mechanism , macros, create multiple environments and the ability to call the system shell.

1) The biggest difference IPython and standard Python is that each row Ipython command prompt will be numbered.

Compare two examples, the output variable values seem the same, in fact there are still differences. print statement informal (unofficial) string expression, and simple variable name (bare variable name) uses the formal (official) string expression. In dealing with the custom class instead of built-in classes, this difference will be reflected very clearly.
In [10]: class DoubleRep (object):
....: Def __str __ (self):
....: Return 'Hi, I'm a __str__'
....: Def __repr __ (self):
....: Return 'Hi, I'm a __repr__'
In [11]: dr = DoubleRep ()
In [12]: print dr
Hi, I'm a __str__
In [13]: dr
Out [13]: Hi, I'm a __repr__

2) tab completion
As an example, we first introduced the sys module, then re-enter sys. (Note that there is a point), then press the tab key, IPython will list all the methods and properties under the sys module.

Continuing the above example, we enter sys? Re-enter, it will show the docstring and related information sys module. Many times this is a very handy feature.

3) history mechanism
hist can quickly see that the history of the input.
hist -n can quickly view and remove the history of the number, so you can easily copy the code into a text editor.
A simpler method is to add slice edit Python list (slice) syntax:
4 edit: 7% to export the first sentence of 4,5,6,7 code to the editor

4) breakpoint debugging: If your program is started from the command line, ie input python foo.py (most Python programs are) in the command line, you can also use IPython anywhere in your program be breakpoint debugging.
Anywhere in your application, add the following statement:
from IPython.Shell import IPShellEmbed
IPShellEmbed ([]) ()
Note: IPython recently released version 0.11, all changes are very large, API has also been redesigned. If you are using two lines corresponding to 0.11 so it is this:
from IPython import embed
embed ()
And then run your program as usual, you will find that when the program is run to place the insert statement, it will go to the next IPython environment. You can try to run some commands, you will find at the moment IPython environment is, at that point in the program. You can step through the various variables in the current state, call the various functions, the output value you are interested in to help debug. Then you can exit IPython as usual, then the program will continue to run down, naturally you execute the statement at the time IPython also affect the next program run.
This method is here (http://lukeplant.me.uk/blog/posts/exploratory-programming-with-ipython/) to see. Imagine doing so as to make high-speed operation of the program paused, then you run the program to check and modify, and then let him continue to run down. To give an example, such as writing web bot, you get back a page in each post you have to look at its contents, and then try to address how to deal with him to get to the next page. Using this technique, you can let the program after retrieving the page break, and then experiment where various treatment methods, to find the right way to handle write back to your code, then the next step. This workflow is only dynamic language like Python that can be done.
- Git Experience Sharing - Using a remote repository (Linux)
- System Security: Build Linux with LIDS steel castle (Linux)
- How to Install Focuswriter 1.4.5 (Linux)
- Java by Spy Memcached to cache data (Programming)
- Linux System Tutorial: How to Check MariaDB server versions (Database)
- HTTPS Encryption Algorithm (Linux)
- CentOS6.7 text installation system (Linux)
- Using Linux stat command to view the files (Linux)
- ARM constant expression (Programming)
- Ubuntu install Vendetta Online 14.04 (Linux)
- MySQL bulk insert data script (Database)
- Redis application of Sina Weibo (Database)
- PostgreSQL 9.3.5 database installation under Ubuntu Server 14.04 (Database)
- Hands to teach you to solve Ubuntu error message (Linux)
- RedHat Redis Linux installation (Database)
- Source Analysis: Java object memory allocation (Programming)
- ORA-38856: Unable instance UNNAMED_INSTANCE_2 (redo thread 2) marked enabled (Database)
- Help you make Git Bisect (Linux)
- 10 really interesting Linux command (Linux)
- Linux kernel socket protocol stack routing lookup cache mechanism (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.