Exploring the code object of a function

suggest change

CPython allows access to the code object for a function object.

The __code__object contains the raw bytecode (co_code) of the function as well as other information such as constants and variable names.

def fib(n):
    if n <= 2: return 1
    return fib(n-1) + fib(n-2)
dir(fib.__code__)

def fib(n):
    if n <= 2: return 1
    return fib(n-1) + fib(n-2)
dir(fib.__code__)

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents