Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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")

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

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.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top