![MicroPython Cookbook](https://wfqqreader-1252317822.image.myqcloud.com/cover/609/36698609/b_36698609.jpg)
There's more...
Using human-readable color names can improve code readability. The technique described in this recipe, however, requires you to specify each color name and its associated hex code manually. This is fine if you are only using a small number of colors, but if you want to support a large number of colors, then this can become very tedious. Another factor to bear in mind is that many of these boards have limited memory capacity, so creating very large dictionaries can cause the board to run out of memory. A small color lookup table, such as the one shown in this example, shouldn't cause these sorts of issues.
When you are looking for color names and their associated hex codes, there are a number of standard sources that can be used. One popular list of color names is the World Wide Web Consortium (W3C), which is used in CSS. There is also a standard color list provided with the open source text editor, Vim. This list of color names is stored in a file called rgb.txt, which comes with each Vim installation.
The benefit of using this color listing is that it comes in a machine-readable format, where each line represents one color and the color components and names are whitespace-delimited. This makes parsing and using these color names a relatively trivial process. The following screenshot shows the output of a useful Vim script that parses this file and presents each color name and its applied color for easy selection:
![](https://epubservercos.yuewen.com/F0709B/19470378808809006/epubprivate/OEBPS/Images/6c942081-50b5-4340-a7e3-35462c0e0f18.png?sign=1739594231-gG3yV39yB6C9UnMMPACAnZDZ66n65pbh-0-c9868e529ff35778b8e0a133eb7ffc2a)