Suppose I had two functions within another function like so:
def FooBar(isTheWorldRound = True):
def Foo():
print("Hi, I'm foo.")
def Bar():
print("Hi, I'm bar.")
theFunction = None
if (isTheWorldRound):
return Bar
else:
return [Bar, Foo]
So, I can do this:
myFunction = FooBar(False)
myFunction()
>>> Hi, I'm Bar
>>> Hi, I'm Foo
Concerning this example I have two questions:
- What is the proper way to perform the commented line?
- Is there a way I can do this without explicitly defining
Foo
?