|
1 | | -"""Word completion for GNU readline 2.0. |
| 1 | +"""Word completion for GNU readline. |
2 | 2 |
|
3 | | -This requires the latest extension to the readline module. The completer |
4 | | -completes keywords, built-ins and globals in a selectable namespace (which |
5 | | -defaults to __main__); when completing NAME.NAME..., it evaluates (!) the |
6 | | -expression up to the last dot and completes its attributes. |
| 3 | +The completer completes keywords, built-ins and globals in a selectable |
| 4 | +namespace (which defaults to __main__); when completing NAME.NAME..., it |
| 5 | +evaluates (!) the expression up to the last dot and completes its attributes. |
7 | 6 |
|
8 | | -It's very cool to do "import sys" type "sys.", hit the |
9 | | -completion key (twice), and see the list of names defined by the |
10 | | -sys module! |
| 7 | +It's very cool to do "import sys" type "sys.", hit the completion key (twice), |
| 8 | +and see the list of names defined by the sys module! |
11 | 9 |
|
12 | 10 | Tip: to use the tab key as the completion key, call |
13 | 11 |
|
14 | 12 | readline.parse_and_bind("tab: complete") |
15 | 13 |
|
16 | 14 | Notes: |
17 | 15 |
|
18 | | -- Exceptions raised by the completer function are *ignored* (and |
19 | | -generally cause the completion to fail). This is a feature -- since |
20 | | -readline sets the tty device in raw (or cbreak) mode, printing a |
21 | | -traceback wouldn't work well without some complicated hoopla to save, |
22 | | -reset and restore the tty state. |
| 16 | +- Exceptions raised by the completer function are *ignored* (and generally cause |
| 17 | + the completion to fail). This is a feature -- since readline sets the tty |
| 18 | + device in raw (or cbreak) mode, printing a traceback wouldn't work well |
| 19 | + without some complicated hoopla to save, reset and restore the tty state. |
23 | 20 |
|
24 | | -- The evaluation of the NAME.NAME... form may cause arbitrary |
25 | | -application defined code to be executed if an object with a |
26 | | -__getattr__ hook is found. Since it is the responsibility of the |
27 | | -application (or the user) to enable this feature, I consider this an |
28 | | -acceptable risk. More complicated expressions (e.g. function calls or |
29 | | -indexing operations) are *not* evaluated. |
| 21 | +- The evaluation of the NAME.NAME... form may cause arbitrary application |
| 22 | + defined code to be executed if an object with a __getattr__ hook is found. |
| 23 | + Since it is the responsibility of the application (or the user) to enable this |
| 24 | + feature, I consider this an acceptable risk. More complicated expressions |
| 25 | + (e.g. function calls or indexing operations) are *not* evaluated. |
30 | 26 |
|
31 | 27 | - When the original stdin is not a tty device, GNU readline is never |
32 | | -used, and this module (and the readline module) are silently inactive. |
| 28 | + used, and this module (and the readline module) are silently inactive. |
33 | 29 |
|
34 | 30 | """ |
35 | 31 |
|
|
0 commit comments