Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
66c52775
Commit
66c52775
authored
Jul 02, 2008
by
Facundo Batista
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #449227: Now with the rlcompleter module, callable objects are
added a '(' when completed.
parent
146b7ab8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
9 deletions
+20
-9
Doc/library/rlcompleter.rst
Doc/library/rlcompleter.rst
+3
-3
Lib/rlcompleter.py
Lib/rlcompleter.py
+14
-6
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/rlcompleter.rst
View file @
66c52775
...
...
@@ -20,9 +20,9 @@ Example::
>>> import readline
>>> readline.parse_and_bind("tab: complete")
>>> readline. <TAB PRESSED>
readline.__doc__ readline.get_line_buffer
readline.read_init_file
readline.__file__ readline.insert_text
readline.set_completer
readline.__name__ readline.parse_and_bind
readline.__doc__ readline.get_line_buffer
( readline.read_init_file(
readline.__file__ readline.insert_text
( readline.set_completer(
readline.__name__ readline.parse_and_bind
(
>>> readline.
The :mod:`rlcompleter` module is designed for use with Python's interactive
...
...
Lib/rlcompleter.py
View file @
66c52775
...
...
@@ -92,6 +92,11 @@ class Completer:
except
IndexError
:
return
None
def
_callable_postfix
(
self
,
val
,
word
):
if
callable
(
val
):
word
=
word
+
"("
return
word
def
global_matches
(
self
,
text
):
"""Compute matches when text is a simple name.
...
...
@@ -102,12 +107,13 @@ class Completer:
import
keyword
matches
=
[]
n
=
len
(
text
)
for
list
in
[
keyword
.
kwlist
,
__builtin__
.
__dict__
,
self
.
namespace
]:
for
word
in
list
:
for
word
in
keyword
.
kwlist
:
if
word
[:
n
]
==
text
:
matches
.
append
(
word
)
for
nspace
in
[
__builtin__
.
__dict__
,
self
.
namespace
]:
for
word
,
val
in
nspace
.
items
():
if
word
[:
n
]
==
text
and
word
!=
"__builtins__"
:
matches
.
append
(
word
)
matches
.
append
(
self
.
_callable_postfix
(
val
,
word
)
)
return
matches
def
attr_matches
(
self
,
text
):
...
...
@@ -139,7 +145,9 @@ class Completer:
n = len(attr)
for word in words:
if word[:n] == attr and word != "
__builtins__
":
matches.append("
%
s
.
%
s
" % (expr, word))
val = getattr(object, word)
word = self._callable_postfix(val, "
%
s
.
%
s
" % (expr, word))
matches.append(word)
return matches
def get_class_members(klass):
...
...
Misc/NEWS
View file @
66c52775
...
...
@@ -33,6 +33,9 @@ Core and Builtins
Library
-------
- Issue #449227: Now with the rlcompleter module, callable objects are added
"(" when completed.
- Issue #3190: Pydoc now hides the automatic module attribute __package__ (the
handling is now the same as that of other special attributes like __name__).
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment