Python eval() - Evaluate Expressions Dynamically

preview_player
Показать описание
The built-in Python function `eval()` is used to evaluate Python expressions. You can pass a string containing Python, or a pre-compiled object into `eval()` and it will run the code and return the result.

Although Python's `eval()` is an incredibly useful tool, the function has some important security implications that you should consider before using it. In this course, you'll learn how `eval()` works and how to use it safely and effectively in your Python programs.

Рекомендации по теме
Комментарии
Автор

Very clear explained. Thank you for sharing your expertise.

marekjablonski
Автор

thanks so much i had a problem in a code
that had to do something like this
create a variable (var_1) that would be 1 of a list of complex variables ) or could be 1 class from a list of dataclasses
i needed to load data in to a variable
but the variable is defined only in execution
and this works
code = "variable_1 = " + + "()"
exec(code)
thanks <3<3

ivanweiss