Search notes:

Python standard library: inspect

import inspect

def xyz(ab, cd = 'foo bar', ef = 42):
    pass


a  = inspect.getargspec(xyz)

print "Arguments:"
for arg in a.args:
    print "  " + arg


print "\nDefaults:"
for def_ in a.defaults:
    print "  " + str(def_)


# Arguments:
#   ab
#   cd
#   ef
# 
# Defaults:
#   foo bar
#   42
Github repository about-python, path: /standard-library/inspect/script.py

getsource

import inspect

def F(a):
    print(f'F says {a}')

print(inspect.getsource(F))
Github repository about-Python, path: /standard-library/inspect/getsource.py

See also

standard library

Index