user2620625
user2620625

Reputation:

Can't Use Tab in Python Shell

Using tab in Python 3.4, I get the following message:

Display all 184 possibilites? (y or n)

Is there a way to allow tabbing in Python 3.4?

Upvotes: 17

Views: 11720

Answers (5)

Jan Kyu Peblik
Jan Kyu Peblik

Reputation: 1537

This should be fixed (reverted) in more recent versions of 3.4 and 3.5, and presumably all future versions for the foreseeable future.

http://bugs.python.org/issue23441#msg247482

Upvotes: 1

Dolda2000
Dolda2000

Reputation: 25865

To edit this behavior out without having to set environment variables for your whole account, you can do the initialization in ~/.local/lib/python3.4/site-packages/usercustomize.py. As @HaleemurAli wrote, the code to disable tab-completion is:

import readline  
readline.parse_and_bind("set disable-completion on")  
readline.parse_and_bind("tab: self-insert")

Upvotes: 2

cybervigilante
cybervigilante

Reputation: 261

So how do I do that in windows? This is a big pain in the neck.

Actually, the simple solution was to get the excellent free autohotkey keyboard programmer, and put this in the .ahk file ;')

Tab:: Send {Space}{Space}{Space}{Space}

(Your editor doesn't show the fact that Send *** is on the second line.)

Upvotes: 0

Haleemur Ali
Haleemur Ali

Reputation: 28313

Instead of tabbing you can use spaces. And in the interactive interpreter, you don't have to type out 4 spaces. Here I'm using two spaces to minimize the number of keystrokes.

if 1 == 1:
  print('Hello Kitty')
  print('Oh no, only two spaces for a new block')

To disable tab: complete, you can do the following.

Create or edit a file on your home directory called .pythonrc
In the file add the following lines and save

import readline  
readline.parse_and_bind("set disable-completion on")  
readline.parse_and_bind("tab: self-insert")

Edit your ~/.bashrc file and add the following line

export PYTHONSTARTUP=$HOME/.pythonrc

Start the python3 interpreter. Tab should work like it used to.

Or, you can bind complete to another key instead of tab, and you would get the proverbial best of both worlds.

Upvotes: 11

Ned Deily
Ned Deily

Reputation: 85125

This is a change introduced in the development versions of Python 3.4. It has been somewhat controversial. You might want to voice your opinions on the issue.

Upvotes: 16

Related Questions