New submission from Cherniavsky Beni <[email protected]>:
IDLE defaults to indenting with 4 spaces in editor windows, but hard TABs in
the Python Shell window. This is inconsistent with PEP 8; what's worse, it's
makes copy-paste code between the shell and editor windows confusing and
dangerous!
Recently I gave a 3-day Python course to 6 people. I spent some time
explaining the dangers of TABs with Python's indentation-sensitive syntax and
telling them "just use 4 spaces and all will be OK". A few hours later one of
them asked me why IDLE is refusing to run his code. Turns out he copy-pasted
code he tried out in the shell, edited it and tried running it, which resulted
in a mix of tabs and spaces (which triggered IDLE's tabnanny check) and a
mixture of 4 and 8 indents (which is ugly).
I had to explain IDLE's confusing behavior, introduce them to Untabify, and
apologize for the inconvenience. All this TABs stuff (and Untabify) are things
people should eventually learn - but they shouldn't bite them on their first
day! (This is what Ubuntu calls a "papercut".)
The rationale for the current behavior seems to be making indentation clear
despite the prompt offsetting the first line by 4:
>>> for i in range(3):
print i
There are 3 alternative behaviors that would be better:
(1) Use 8 spaces instead of a TAB.
(2) Use 4 spaces.
(3) Use 4 spaces, but add a GUI left margin of 4 to continuation lines.
(3) would be ideal, making copy-paste work cleanly while looking good. I'm not
sure if it can be implemented easily, but I'll look into it.
If it's hard, (2) would still be a big improvement IMHO. I think correct
behaviour is more important than looking good after ">>> " - but others may
disagree on this.
If there is doubt, (1) is still strictly an improvement. It can lead to mixed
8/4 spaces - but at least there won't be invisible problems that the user
doesn't understand.
[Configurability concerns: all I said above refers to the *default* behavior of
IDLE, which should follow 4-spaces. The user should be able to configure it to
use another width, or TABs. This option already exists - but it's ignored
outright by the shell window. Solutions (2) and (3) would make the shell
window respect it.]
----------
components: IDLE
messages: 97586
nosy: cben
severity: normal
status: open
title: IDLE shell shouldn't use TABs
type: behavior
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue7676>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com