hi everyone :) my problem is, up until now, i have exclusively used tabs to indent python, as i find it easier than spaces, but for no reason i know, python interactive prompt, the basic python.exe one, suddenly refuses to accept the tab button, all it does is flash the cursor. all i can think of is that my computer in suddenly treading the window like any other, using tab to cycle input things, in this case the single one. also, before now, i could use the up button to reach previously typed code, the if i submit that line with no changes, use the down button to access the line that came after it, but now up works, but as if i had changed the line, eg moves me back to the "bottom" of the list of inputs, so down doesn't work.... my question simply is: how do i get my good old tab and down button to work like i want them to again? :( thanks xxx
-
5Do not use tabs to indent Python code. A reasonable editor will make indenting with spaces much easier than tabs. Seriously, don't ever use tabs.Rafe Kettler– Rafe Kettler2011-03-13 18:38:41 +00:00Commented Mar 13, 2011 at 18:38
-
What OS are you using? I'm using Ubuntu linux and my tab is working fine ). Also, there is a python recommendation to use spaces instead of tabs. See Code lay-out section.ikostia– ikostia2011-03-13 18:40:05 +00:00Commented Mar 13, 2011 at 18:40
-
@ikostia he's using Windows, I guess, and that's why his CLI is weird (cmd.exe is terrible)Rafe Kettler– Rafe Kettler2011-03-13 18:40:38 +00:00Commented Mar 13, 2011 at 18:40
-
dont dis tabs. i like them. int the interactive prompt, i want a easily visible intent that takes one button press. voila, tab.jma– jma2011-03-13 18:42:26 +00:00Commented Mar 13, 2011 at 18:42
-
2@James if you use ipython or bpython then indentation is taken care of for you. Tabs are like smoking: you might enjoy it but they're harmful to you and everyone around you.Rafe Kettler– Rafe Kettler2011-03-13 18:43:01 +00:00Commented Mar 13, 2011 at 18:43
2 Answers
If you are using Windows with the standard cmd.exe console (and it would have been helpful for you to have stated this up front) then you can use the TAB and arrow keys exactly as you desire.
2 Comments
I recently observed this behavior too, on Windows, using cmd.exe. It also happens with Console2 - an alternate shell I sometimes use.
Though I do always use spaces in normal code in an editor, I had been accustomed to using the Tab key to indent in short multi-line inputs in the interactive python.exe interpreter. Recently that stopped working - pressing the Tab key flashes the cursor and doesn't indent. Using spaces does work fine here, though it's not as convenient past a couple of indentations.
I suspect (but am not certain) that the cause was installation of pyreadline or rlcompleter - I had been messing with trying to get tab completion in an interpreter in an embedded application on Windows. Of course in your case another installation could have included those packages.