I would like to know if it is possible to configure IDLE to show those variables that I have defined in a Python code in a different color. I would find it very useful when writing Python code, as it would help you to track which variables have been defined, and to locate them in case you want to change their names. Does this option exist?
The short answer is no, but it is not quite clear what you are asking for. All global and local names are variables in the sense that they can be rebound to other objects. Consider the following nonsensical code:
import itertools
import tkinter as tk
def f(): return int('3g', 20
text = tk.Text(width=f())
import
, as
, and def
are keywords and IDLE highlights them as such. int
is a builtin and IDLE highlights it as such. itertools
, tk
, f
, and text
are global variables defined in the code. IDLE highlights f
where it is defined, in the def statement, but otherwise leaves them alone. Which of the other occurrences would you like always highlighted?
I personally think it would be too much clutter if all occurrences of all variables were always highlighted. IDLE could highlight itertools
and tk
where defined, in the import statements, but this does not seem very useful. What I do think useful, from experience with other software, and am thinking about adding to IDLE, is being able to temporarily highlight all occurrences of one name.