14.3. Executable Object Statements and Built-in Functions

Python provides a number of built-in functions supporting callables and executable objects, including the exec statement. These functions let the programmer execute code objects as well as generate them using the compile() built-in function and are listed in Table 14.6.

Table 14.6. Executable Object Statements and Built-in Functions
Built-in Function or StatementDescription
callable(obj)determines if obj is callable; returns 1 if so, 0 otherwise
compile(string, file, type)creates a code object from string of type type; file is where the code originates from (usually set to ″)
eval(obj, globals=globals(), locals=locals())evaluates obj, which is either a expression compiled into a code object ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.