4

How can I check for spelling errors in Python code?...

  1. Check spelling in all strings delineated with double quotes (") or single quotes (').
  2. Check spelling in all comment lines (lines that start with a # symbol).

Of course, I expect false-positives, since not all quote delineated strings or code comments always have English words.

However, the important thing is that the spell checker should ignore actual lines of code, and report results only for items 1 and 2 above.

(By the way, I use gedit as my IDE).

3
  • 3
    Consider using PyCharm, it comes with a spellcheck that does what you are asking and also checks regular code for typos. This is relevant because you might misspell a certain word used as a function/variable name, then fail to find a piece of code by searching with the correct orthography.
    – Mefitico
    Feb 17, 2020 at 16:22
  • There is a spell checker plug-in for gedit but AFAIK it spell checks everything. Feb 17, 2020 at 17:17
  • Yes, I use the gedit spell check plugin, and it does check everything.
    – Enterprise
    Feb 20, 2020 at 2:56

1 Answer 1

3

The simplest way is to use PyCharm, it's one of Jetbrains IDEs in the market. It provides the functionality of spelling check, which you can enable/disable it by double click on shift button and search for Spelling Error.

enter image description here

One more interesting thing is that you can have a customized dictionary for your environment. To do so, you can install hunspell plugin for the same IDE too.

1
  • I tried the community version... It actively underlines misspelled words in comments and strings. It intelligently excludes flagging variable names in comments and strings (so there are pleasantly fewer "false positives"). It offers spelling suggestions and can even inspect your entire project. I wish a PPA were offered (I'm not a fan of snap, so I opted to download the tar file). Also it doesn't use a native look and feel, but there are no unusual or salient glitches in the UI. Overall, I'll try this for my project-- it has the spell check features I was looking for.
    – Enterprise
    Feb 20, 2020 at 2:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .