Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In python shell, "b" letter does not work, what the?

Tags:

python

shell

Well hello, this is the most interesting bug/conflict I've ever faced.

In python shell, I cannot type lowercase "b". At first I thought something was under the key, but no, in everywhere else it functions very well. Also ctrl+b shift+b even with capslock b works.

Yet more, when I run the shell with sudo (ie. sudo python), my little lowercase "b" works well.

My last move was installing pyexiv2 (using aptitude), I can import it without problems in both with and without sudo. I have removed it but the result didn't change.

What the hell might be wrong?

I am using Ubuntu 10.04 LTS x86 with Python 2.6.5

Further note:
I have installed a vim modifier script which might be the trouble.
Using this:

$ git clone https://github.com/sontek/dotfiles.git
$ cd dotfiles
$ ./install.sh vim

This scripts initiates more git clones, so it might be hard to follow. But it does many changes including the terminal's look.

UPDATE:

1) I even cannot copy/paste "b" character. ctrl+c/v select&middle click both doesnt work.

2) When I open the shell with python -E, the modifiers from the mentioned so called vim script does not appear. And b works well. When I open it with python or python -S the modifications exists and i cannot type b.

3) Good news: I have managed to locate the fault, it is the so called vim script. I have renamed its folder and it worked fine. In couple of hours, I will examine deeply what exactly causes the problem and post it here with detailed results.

like image 278
Umur Kontacı Avatar asked Aug 19 '11 15:08

Umur Kontacı


People also ask

What is the shell for in Python?

The Python Shell is the interpreter that executes your Python programs, other pieces of Python code, or simple commands.

How do I enable Shell in Python?

To run the Python Shell, open the command prompt or power shell on Windows and terminal window on mac, write python and press enter. A Python Prompt comprising of three greater-than symbols >>> appears, as shown below. Now, you can enter a single statement and get the result.


2 Answers

The problematic line in your .pythonstartup is something like:

 readline.parse_and_bind("bind ^I rl_complete") # darwin libedit

This .pythonstartup will fix it...

try:
    import readline
except ImportError:
    print "Module readline not available."
else:
    import rlcompleter
    if 'libedit' in readline.__doc__:
        readline.parse_and_bind("bind ^I rl_complete")
    else:
        readline.parse_and_bind("tab: complete")
like image 166
Gregg Lind Avatar answered Sep 27 '22 20:09

Gregg Lind


My money is that the readline on your shell is messed up. Perhaps the 'b' key is bound to auto-complete. Look in your PYTHONSTARTUP variable and see what file it refers to. If that file has something like readline.parse_and_bind ...

I'm betting there's some connection between the fact that it's 'b' (instead of some other letter) and the word 'bind', like there's a variable called bind_to_complete and it's being interpreted literally (and only the first character taken).

Let the mass wild-ass guessing commence!

like image 20
Michael Lorton Avatar answered Sep 27 '22 19:09

Michael Lorton