This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: IDLE not smart indenting correctly in nested statements
Type: behavior Stage: needs patch
Components: Interpreter Core Versions: Python 3.2, Python 3.3, Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: IDLE shell shouldn't use TABs
View: 7676
Assigned To: Nosy List: Tofystedeth, cben, mark.dickinson, terry.reedy
Priority: normal Keywords:

Created on 2010-04-01 20:50 by Tofystedeth, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg102134 - (view) Author: (Tofystedeth) Date: 2010-04-01 21:24
huh, somehow I submitted this before I was done, sorry bout that.

IDLE (the shell, not the text editor) doubles the indentation when in nested statements.
For instance
while True:
    while True:
        while True:

>>> while True:
        while True:
                while True:
backspacing removes all 8 spaces as well, so once I'm nested that far I have to manually indent.
msg113007 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-08-05 18:49
I don't think this is specific to IDLE;  it also happens when launching the python interpreter directly from a terminal on OS X or Linux.  (BTW, what platform are you on?)

As far as I can tell, the TAB character is simply advancing to the next tab stop;  those tab stops are determined by the terminal, and can be controlled with the 'tabs' command on Linux.  Though if you're using the readline library, that seems to override or reset the tab settings somehow.
msg113026 - (view) Author: (Tofystedeth) Date: 2010-08-05 19:20
You're right, it also does it when I use the Python shell from the command prompt.  I'm running Windows Vista 32bit SP2.
msg151413 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2012-01-16 22:32
The current indentation is a consequent of using tabs for indents.
Changing that is the subject of #7676.
#1196946 is a similar issue.
msg151433 - (view) Author: Cherniavsky Beni (cben) * Date: 2012-01-17 09:07
Mark: customizing tabs to be anything but 8 spaces is inadvisable with Python, because Python always parses them as 8.
Sooner or later one would mix tabs and spaces and the result would be really painful to debug.
Date User Action Args
2022-04-11 14:56:59adminsetgithub: 52532
2012-01-17 09:44:03taleinatsetnosy: - taleinat
2012-01-17 09:07:16cbensetnosy: + cben
messages: + msg151433
2012-01-16 22:32:41terry.reedysetstatus: open -> closed

superseder: IDLE shell shouldn't use TABs
versions: + Python 3.3, - Python 3.1
nosy: + terry.reedy

messages: + msg151413
resolution: duplicate
2010-08-05 21:11:51terry.reedysetnosy: - terry.reedy
2010-08-05 19:20:53Tofystedethsetmessages: + msg113026
2010-08-05 18:49:06mark.dickinsonsetnosy: + mark.dickinson
messages: + msg113007
components: + Interpreter Core, - IDLE
2010-08-05 04:13:38BreamoreBoysetnosy: + terry.reedy, taleinat
stage: needs patch

versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2010-04-01 21:24:38Tofystedethsettype: behavior
messages: + msg102134
2010-04-01 20:50:22Tofystedethcreate