exec()

A built-in function that runs a string of Python source code as statements, used in labs to show an error without stopping the whole program.

In more detail

Errors in the code it runs are raised at the exec call, so a try statement around it can catch even a SyntaxError. compile() with the mode 'exec' checks the same source without running it. Never pass exec text from an untrusted user.

Related terms

Taught in

References

Certification courses