basic programming python: Python see how IPython to improve development efficiency

A, IPython Profile

IPython is an interactive Python interpreter, but it is more efficient.

It mostly traditional mode of operation (Edit -> compile -> run) different is that it uses a mode of operation: Execution -> explore, and most of the data analysis and associated generation

Contain exploratory operation code (such as trial and error method and iterative method), so IPython can greatly improve the coding efficiency.

IPython to the present, it is not just an enhanced version of the Python shell, and it integrates GUI console, which allows you to directly drawing operations; it also has an interactive Web-based laptop and a lightweight fast parallel computing engine.

Second, write code

In the Terminal Input ipython can start IPython.
If you need to use Matplotlib library, you need to mark the start time Matplotlib integrated package, the startup command instead: ipython --pylab

  1. Learn to use the Tab key

Pressed the Tab key to automatically after completion at the time of input of the code, if it is a content already entered (such as the previously defined variables), you only need to enter the first few letters.
IPython have this function is a major improvement over the standard Python shell, which is already very common in other languages IDE.

Not only can auto-complete variables, objects, etc., like typing the command in the Terminal as the Tab key can also automatically complete file path.

  1. Up and down arrow keys to quickly enter the command history

When a command or code that may need to repeatedly input, do not knock again manually every time, only need to use the arrow keys on either automatically fill command on the whole; press was continued at this time is on the upper arrow key command.
If a command needs to press the up arrow key several times to find, then just type the first few letters of that command and then press the up arrow key, you can only screened in line with the first few letters of the command.

  1. Execute a .py file

If you want to perform an external .py file, using the% run command, for example: Here Insert Picture Description
4. Review the general information related to code

When you need to view a variable or object general information related to the time after this variable to add a question mark and then press the Enter key. For example: Here Insert Picture Description
If a function contains docstring, add a question mark after the function name can also view the contents of the docstring; (?)
If you add two question marks (??) after the function name, you can display the functions related source code, for example: Here Insert Picture Description
the encoding process associated with the shortcut keys
Ctrl + F cursor forward one character
Ctrl + B after the cursor is moved one character
Ctrl + a cursor to the beginning of the line
Ctrl + E cursor to end of line
Ctrl + U delete all the contents of the cursor before this line
everything after the Ctrl + K to delete this line cursor
Ctrl + L to clear the screen (Mac under Cmd + K may be)

Third, debugging code

  1. After the code is abnormal start the debugger

After the occurrence of the fault code, enter% debug command to start the debugger and automatically jump to the "site of the incident": Here Insert Picture DescriptionEnter the q command to exit the debugger.

  1. Single-step execution

% Run command with the -d option may be pre-opened debugger s input step into a function call, n command input to the next line of code, input exclamation mark (!) Followed by the input variable name to view variable values. For example: Here Insert Picture Description
This command If you add a specified line number option (-b) to set a breakpoint in the debugger is started, for example: Here Insert Picture Description
in fact, there is not only technical, more technical stuff than those, for example, how do a fine programmer, rather than "Cock wire"

Programmer itself is a noble presence, ah, is not it?
Content on more than how many, and finally to recommend a good reputation

No. [programmers] public universities, there are a lot of old-timers learning skills, learning experience, interview skills, workplace experience and other share, more

We carefully prepared the zero-based introductory information, information on actual projects, the timing has to explain the Python programmer technology every day, share some learning

Methods and need to pay attention to small details, you are welcome to join, the future, beyond coding, there you have me do with a person not

Silly, a lot of money, live a long happy programmer now!Here Insert Picture Description

Published 81 original articles · won praise 18 · views 70000 +

Guess you like

Origin blog.csdn.net/chengxun02/article/details/105205582