Terry J. Reedy <tjre...@udel.edu> added the comment:

Raymond, which definition of 'whitespace' do you intent?

Git gui also marks trailing spaces in frozen diffs.  This is much harder to do 
while editing as text can be read, keyed, and pasted.  Most spaces and blank 
lines are only temporarily trailing, before something more is added.  I believe 
I would dislike the idea of temporarily marking them, unless it were very 
subtle.  They really only need to be stripped just before saving.  So I think 
we should make that easy and not too intrusive. 

1. Ask if there is trailing whitespace.  For instance,
    if (text.find('\s\n') != -1) or <text ends with '\n\n'>:
        <Query 'strip?', with 'Yes' the default for .py files>

2. Add a setting to strip on save, default yes.

3. always strip trailing whitespace from .py files when saving.
Perhaps flash 'trailing whitespace stripped' to status bar.

The danger with any of these is stripping of wanted trailing whitespace in 
tripple-quoted string literals.  Such whitespace is rare, but I don't know how 
rare.

Alternate ways of making such are better in making the blanks permanently 
visible in any display, not just in IDLE.  The problem is teaching this.

>>> s = (
  'This is justified text\n'
  'with blank spaces.    \n'
  'It is is followed by  \n'
  'a trailing blank line.\n'
  '\n')
>>> s
'This is justified text\nwith blank spaces.    \nIt is is followed by  \na 
trailing blank line.\n\n'

while an error marking would tell users to do it manually.
---

I closed PR 1644 because implementing features as extensions is obsolete and 
because the trim function duplicates the existing function (once it is fixed to 
include blank lines).

I am dubious about PR 1643.  Tagging trailing whitespace as an error would 
suggest that the user should delete it.  With strip on save, this would be 
noise.

----------
stage: patch review -> needs patch
versions: +Python 3.8 -Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue23667>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to