How do I use inspection to retrieve a list of sub-functions?
def f( x, y):
def g( a ):
return a + 1
def h( z ):
return b + 1
subs = inspect.getsubfunctions( f )
#Should return [ g, h ]
How do I use inspection to retrieve a list of sub-functions?
def f( x, y):
def g( a ):
return a + 1
def h( z ):
return b + 1
subs = inspect.getsubfunctions( f )
#Should return [ g, h ]
You can't. The "subfunctions" don't exist until the function is called. Even once it's called, the g and h definitions create new, mostly-identical functions on each f call, so you can't get the g function or the h function.