Python IDLE Syntax Highlighting

Python’s IDLE code editor comes with every standard Python installation in Windows, Linux, and macOS. You can use it right out of the box after installing Python on your computer.

Related Article: How to Install Python?

IDLE has a useful syntax highlighting feature that highlights different Python language features to help you grasp source code faster:

Python IDLE - Code Highlighting Example
  • Python keywords may be colored orange.
  • Function names may be colored blue.
  • Strings may be colored yellow.
  • Variable names may be white.

You can change the syntax highlighting theme by clicking Options > Configure IDLE and switching to the Highlights tab.

Python IDLE change code highlighting theme

Here’s how I changed the code highlighting theme in my own IDLE from a dark to a light theme and back:

Change Code Highlighting IDLE Python Gif

You can choose among the following three default themes:

  • IDLE Classic
  • IDLE Dark
  • IDLE New

Here are all three variants available in the IDLE editor per default for you to compare. Which one do you like most?

IDLE Classic Theme
IDLE Classic
IDLE Dark Theme Example
IDLE Dark
IDLE New Theme Example
IDLE New

Troubleshooting

What if IDLE doesn’t highlight your syntax but the code appears in black color only?

The most common source of this problem is that you opened a file with another file suffix than .py, for example a text file .txt or a data file .dat. The IDLE editor will highlight only Python’s standard .py files. To fix this issue, simply rename the file from the non-Python file suffix to the Python file suffix. For example, rename the file from code.txt to code.py and reopen the file. As a result, the code will be highlighted in IDLE.

Here’s an example of the same code opened as a .txt and as a .py file—being highlighted only in the latter case.

Fix IDLE Error: Highlighting not working

Thanks for taking the time to read over this article! Frankly, I still use IDLE for many of my Python projects because it opens much faster than PyCharm. If I just want to script some quick problem, nothing is as fast and efficient as opening the IDLE program in your operating system and get going instantly.

Check out our free email academy to become a better Python coder (and download some PDF cheat sheets too!):

Where to Go From Here?

Enough theory. Let’s get some practice!

Coders get paid six figures and more because they can solve problems more effectively using machine intelligence and automation.

To become more successful in coding, solve more real problems for real people. That’s how you polish the skills you really need in practice. After all, what’s the use of learning theory that nobody ever needs?

You build high-value coding skills by working on practical coding projects!

Do you want to stop learning with toy projects and focus on practical code projects that earn you money and solve real problems for people?

🚀 If your answer is YES!, consider becoming a Python freelance developer! It’s the best way of approaching the task of improving your Python skills—even if you are a complete beginner.

If you just want to learn about the freelancing opportunity, feel free to watch my free webinar “How to Build Your High-Income Skill Python” and learn how I grew my coding business online and how you can, too—from the comfort of your own home.

Join the free webinar now!