Given a function within a function, how do I call the inner function from an external function?
ex.
def a():
print 'a'
def b():
print 'b'
def c():
print 'c'
def d():
# how would I now call a, b and c from here?
def e():
# how would I call a, b and c from here as well?
Yes I know it’s horrible code structure and should not be done – but how do you do it?
Edit: Any way to do this using decorators?
You cannot.
bandcare local variables insideaand do not exist except whileais executing.(Since these are constants, you can technically access them via
a.__code__.co_consts, but this is not a real solution even if you’re okay with horrible code structure. You would have to execute the function withexecand you can’t pass arguments to it.)