Reputation: 15
I am new to pragramming and python. This is something like what I have.
Def some_function():
Print "stuff"
Def another_function(x):
running = True
While running:
x
another_function(some_function())
Why does it only print "stuff" the first time going through the loop?
I read some stuff that talked about late binding but not sure if that is what this is or how to fix it in my example.
Upvotes: 1
Views: 40
Reputation: 780843
You didn't pass the function, you called the function and passed its value. So it printed stuff
before you ever got into the loop.
To refer to a function without calling it, you leave off the ()
. So it should be:
another_function(some_function);
Then in another_function
, you have to call the function:
def another_function(x):
running = True
while running:
x()
Upvotes: 1