PY3.W0122

Exec used

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.

Noncompliant Code:

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

Compliant Code:

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

The content on this page is adapted from the Pylint User Guide, Copyright ©2003-2022, Logilab, PyCQA and contributors. All rights reserved. https://pylint.pycqa.org/en/latest/index.html#, and is used under the Python Software Foundation License Version 2. Examples, recipes, and other code in the Pylint documentation are additionally licensed under the Zero Clause BSD License.