I have searched methods of dynamically setting local variables on the Stack Overflow and saw many suggested using setattr
and didn't recommend exec()
(dict()
or vars()
were also suggested, but the first two seem pythonic to me).
But no one tells why exec()
is worse or unsafe.
Could somebody explain this?