Function internals
🔥
Function is wrapper around code object. Code object is wrapper for byte-code.
🪄 Code:
def f1():
return "Hello"
f2 = lambda: "Hello"
print(f1.__code__.co_code)
print(f2.__code__.co_code)
📟 Output:
b'd\x01S\x00'
b'd\x01S\x00'
🪄 Code:
print(f1.__code__.__doc__)
📟 Output:
code(argcount, kwonlyargcount, nlocals, stacksize, flags, codestring,
constants, names, varnames, filename, name, firstlineno,
lnotab[, freevars[, cellvars]])
Create a code object. Not for the faint of heart.
Last updated
Was this helpful?