hitting TAB inserts ./ in interactive mode ?
Ned Deily
nad at acm.org
Mon Sep 20 17:49:47 EDT 2010
In article
<7b7f018e-b429-448b-94c1-2a812c5f3436 at h37g2000pro.googlegroups.com>,
Nik Krumm <nkrumm at gmail.com> wrote:
> The issue isn't with readline. The readline module or rlcompleter
> module are both available, and loading them has no effect on the
> behavior of tab:
>
> >>> import readline
> [Now i hit tab...]
> >>> ./
> File "<stdin>", line 1
> ./
> ^
> SyntaxError: invalid syntax
>
> [Hit tab twice...]
> >>> ./
> ./.bash_history ./.bash_profile ./.bash_profile.pysave
[...]
> So this ostensibly makes it very hard to write or paste any code into
> the command line!
Ah, thanks, I get it now. It turns out this is a bug seen for the
first time with the new-style (32-/64-, 10.5+) python.org 2.7 installer
build because it links with the Apple-supplied editline library rather
than the GNU readline library as in other installers. I've opened an
issue for this:
http://bugs.python.org/issue9907
As noted there, two workarounds come to mind. Either switch to using
the old-style (32-only, 10.3+) 2.7 installer; or, add or modify a
PYTHONSTARTUP file to force the desired TAB behavior, so something like
this:
$ cat > $HOME/.pystartup
import readline
if 'libedit' in readline.__doc__:
readline.parse_and_bind("bind ^I ed-insert")
^D
$ export PYTHONSTARTUP=$HOME/.pystartup
Thanks for reporting this!
--
Ned Deily,
nad at acm.org
More information about the Python-list
mailing list