Can I call a function nested inside another function from the global scope in python3.2?
def func1():
def func2():
print(\"Hello\")
retur
You want to use @larsmans' solution, but theoretically you can cut yourself into the code object of the locally accessible func1 and slice out the code object of func2 and execute that:
#!/usr/bin/env python
def func1():
def func2():
print("Hello")
# => co_consts is a tuple containing the literals used by the bytecode
print(func1.__code__.co_consts)
# => (None, )
exec(func1.__code__.co_consts[1])
# => prints 'Hello'
But again, this is nothing for production code.
Note: For a Python 2 version replace __code__ with func_code (and import the print_function from the __future__).
Some further reading: