Fix gen_dynamic_list.py for Python 3. Patch by Marcoen Hirschberg.