Changeset 388 for python/vendor/current/Lib/rlcompleter.py
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Lib/rlcompleter.py
r2 r388 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 … … 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 - GNU readline is also used by the built-in functions input() and … … 36 32 37 33 - When the original stdin is not a tty device, GNU readline is never 38 used, and this module (and the readline module) are silently inactive.34 used, and this module (and the readline module) are silently inactive. 39 35 40 36 """ … … 121 117 122 118 Assuming the text is of the form NAME.NAME....[NAME], and is 123 evalua table in self.namespace, it will be evaluated and its attributes119 evaluable in self.namespace, it will be evaluated and its attributes 124 120 (as revealed by dir()) are used as possible completions. (For class 125 121 instances, class members are also considered.)
Note:
See TracChangeset
for help on using the changeset viewer.