Trailing whitespaces in triple-quoted string literals

FWIW, Emacs has global-whitespace-mode which I always enable, and which highlights trailing whitespace. I have a personal convenience function that strips TWS from every line in a file, but it’s something I have to explicitly do in my editor, which feels like the right responsibility. And it does occasionally go wrong, such as cases where you are comparing big blocks of text and the trailing whitespace is significant [1].

ObWSJ: You can pry those ^L’s from my Emacs RSI’d fingers! :stuck_out_tongue_winking_eye:

  1. as I remember in some Mailman and/or email package tests ↩︎

My vote is also “no”. I don’t think Python itself should emit syntax warning, but I would expect linters or IDEs to warn users about this.


In your pydoc story, you seemed to be bothered that a test failed because of trailing whitespace differences. If the test was changed to compare in a way that ignores trailing spaces, then that would fix the test.

If you don’t want that, because you do care about what specific trailing whitespace there is, then you need your notation for the expected value to be capable of describing the trailing whitespace.

1 Like

Oh, there’s nothing really interesting. The majority is last-line indentation. Most of the rest are just editing remnants of no consequence. Still, it’s 249 potential SyntaxWarning’s to deal with.

:-1: from me, too. As a maintainer of a lot of legacy code, I’d just not want to go through everything and decide where it’s wanted and where it’s just a minor cosmetic irritant for the ~2% of people, that might actually notice.

About stripping common indentation in the lines of triple quoted blocks, now… :smirk: