|
1 |
| -# 14. Interactive Input Editing and History Substitution |
| 1 | +# 14. Chỉnh sửa ngõ vào tương tác và thay đổi lịch sử |
2 | 2 |
|
3 |
| -Some versions of the Python interpreter support editing of the current input line and history substitution, similar to facilities found in the Korn shell and the GNU Bash shell. This is implemented using the [GNU Readline](https://tiswww.case.edu/php/chet/readline/rltop.html) library, which supports various styles of editing. This library has its own documentation which we won’t duplicate here. |
| 3 | +Một vài phiên bản của trình thông dịch Python hỗ trợ chỉnh sửa dòng hiện tại của đầu vào và thay đổi lịch sử, tương tự như các tính năng ở Korn shell và GNU Bash shell. Tính năng này được triển khai sử dụng thư viện [GNU Readline](https://tiswww.case.edu/php/chet/readline/rltop.html), thư viện hỗ trợ nhiều cách chỉnh sửa khác nhau. Thư viện này có tài liệu riêng của nó, vì vậy sẽ không đề cập lại ở đây. |
4 | 4 |
|
5 |
| -### 14.1. Tab Completion and History Editing |
| 5 | +### 14.1. Hoàn tất sử dụng tab(tab completion) và chỉnh sửa lịch sử |
6 | 6 |
|
7 |
| -Completion of variable and module names is [automatically enabled](https://docs.python.org/3/library/site.html#rlcompleter-config) at interpreter startup so that the Tab key invokes the completion function; it looks at Python statement names, the current local variables, and the available module names. For dotted expressions such as `string.a`, it will evaluate the expression up to the final `'.'` and then suggest completions from the attributes of the resulting object. Note that this may execute application-defined code if an object with a [`__getattr__()`](https://docs.python.org/3/reference/datamodel.html#object.__getattr__) method is part of the expression. The default configuration also saves your history into a file named `.python_history` in your user directory. The history will be available again during the next interactive interpreter session. |
| 7 | +Sự hoàn tất của tên biến và module được [tự động cho phép](https://docs.python.org/3/library/site.html#rlcompleter-config) ngay khi trình thông dịch khởi động vì vậy phím `tab` gọi hàm hoàn thiện; nó nhìn vào tên của phát biểu trong Python, các biến cục bộ hiện hành, và các module có sẵn. Với những biểu thức có dấu chấm như là `string.a`, nó sẽ đánh giá biểu thức cho đến dấu `'.'` cuối cùng và sau đó đề nghị những hoàn thiện từ các thuộc tính của đối tượng kết quả. Lưu ý rằng điều này có thể gây nên đoạn mã được ứng dụng định nghĩa (application-defined) nếu một đối tượng với phương pháp [`__getattr__()`](https://docs.python.org/3/reference/datamodel.html#object.__getattr__) là một phần của biểu thức. Cấu hình mặc định cũng lưu lại lịch sử của bạn vào một file có tên `.python_history` trong thư mục `user/` của bạn. Lịch sử sẽ tiếp tục có sẵn trong suốt phiên tương tác tiếp theo của trình thông dịch. |
8 | 8 |
|
9 |
| -### 14.2. Alternatives to the Interactive Interpreter |
| 9 | +### 14.2. Những thay thế cho trình thông dịch tương tác |
10 | 10 |
|
11 |
| -This facility is an enormous step forward compared to earlier versions of the interpreter; however, some wishes are left: It would be nice if the proper indentation were suggested on continuation lines \(the parser knows if an indent token is required next\). The completion mechanism might use the interpreter’s symbol table. A command to check \(or even suggest\) matching parentheses, quotes, etc., would also be useful. |
| 11 | +Tính năng này là một bước tiến lớn so với những phiên bản cũ hơn của trình thông dịch; tuy nhiên, một vài mong muốn vẫn còn sót lại: thật tốt nếu việc căn lề sao cho đúng được đề cập trong dòng tiếp theo. \(việc phân tích cú pháp parser biết được nếu một dấu hiệu thụt lề được yêu cầu tiếp theo\). Cơ chế hoàn thiện có thể sử dụng bảng ký hiệu của trình thông dịch. Một câu lệnh để kiểm tra (hoặc là đề nghị) những dấu ngoặc, trích dẫn,... tương ứng cũng sẽ rất hữu dụng. |
12 | 12 |
|
13 |
| -One alternative enhanced interactive interpreter that has been around for quite some time is [IPython](https://ipython.org/), which features tab completion, object exploration and advanced history management. It can also be thoroughly customized and embedded into other applications. Another similar enhanced interactive environment is [bpython](http://www.bpython-interpreter.org/). |
| 13 | +Một trình thông dịch thay thế được nâng cấp xuất hiện gần đây là [IPython](https://ipython.org/), nó có những tính năng như hoàn thiện dùng tab, khám phá đối tượng và quản lý lịch sử nâng cao. Nó cũng có thể tùy chỉnh và nhúng triệt để vào trong những ứng dụng khác. Một môi trường tương tác được nâng cấp tương tự là [bpython](http://www.bpython-interpreter.org/). |
14 | 14 |
|
0 commit comments