Follows by the python reference manual
we've that
Code objects represent byte-compiled executable Python code, or bytecode.
and
Special read-only attributes: co_name gives the function name;
What is the value of co_name
if the current compiled code doesn't depends on any function (i.e. global module code)?
>>> print inspect.currentframe().f_code.co_name
<module>
Using inspect
to get the code object of the current stack frame in interactive mode, we find that the co_name
is '<module>'
.