Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab key not indenting in Python

I recently upgraded to python2.7 and noticed that the tab key does not function appropriately in the shell. Instead, it appears to search through the underlying directory (the standard unix behavior).

If I change back over to python2.6, it works appropriately. Is there a way to add this functionality back to 2.7?

For example:

if foo:
(tab here) print 'bar' #desired behavior is that tab key adds indentation here

Solution:
This is a known issue with python2.7 on Mac OSX. I used the following workaround to correct it:

$ cat > $HOME/.pystartup
import readline
if 'libedit' in readline.__doc__:
   readline.parse_and_bind("bind ^I ed-insert")
^D
$ export PYTHONSTARTUP=$HOME/.pystartup
like image 295
Joe Avatar asked May 19 '26 17:05

Joe


1 Answers

This is a known bug with python 2.7 on Mac OSX. More details (including a fix) can be found in the bug report.

like image 103
Thomi Avatar answered May 21 '26 07:05

Thomi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!