It appears that the whitelist variable is only being used to see if the key pressed value is in the list or not. From a DRY perspective, would it be better to use the buttons list of lists variable instead of two different variables that essentially contain the same values? It would seem that using separate variables opens the door for defects if the developer forgets to update both of them.
Good point. I probably would have noticed that if I had reproduced the full code for that example in the text, but I didn't. Regardless, I just fixed the example locally.
In Chapter 6 the following code is used to create the labels for the buttons:
further on in the book the same values are assigned to a different variable:
It appears that the whitelist variable is only being used to see if the key pressed value is in the list or not. From a DRY perspective, would it be better to use the buttons list of lists variable instead of two different variables that essentially contain the same values? It would seem that using separate variables opens the door for defects if the developer forgets to update both of them.