'random' module is used but not imported.
Good catch, thanks for all of these fixes. They are greatly appreciated!
In fact, pylint is helping me to find these kind of issues easily. But the current .pylintrc need some tweaking to be more effective.
Add missing import of random module