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?