pylint-errors

W0122 (exec-used)

:x: Problematic code:

program = input('Enter code to be executed: ')
exec(program)

:heavy_check_mark: Correct code:

programs = {'do_something': lambda: print("Do something")}
program = input('Enter a program code to be used: ')
if programs.get(program):
    programs[program]()

Rationale:

Used when you use the exec statement (function for Python 3), to discourage its usage. That doesn’t mean you cannot use it! It’s dangerous to use this function for a user input.