I have a python program that I am currently working on which is working pretty well except for the fact that I am running into "recursion depth" issues and I am not sure how to rework my program to avoid this.
my program is basically something like this in a nutshell:
def foo()
x = 0 #
while x != 1:
x = (mydll.InPortB(base+1)) & 1 # this is a hardware input like a push button(on or off)
time.sleep(0.5)
bar = ser.readline() # input from serial source
if len(bar) != 10:
foo()
''' it continues checking "bar" using some more if statement. Finally when the
logic is satisfied the program outputs something but still restarts foo() as
I need the program to run endlessly but I am not sure how to fix the recursive
nature of the program'''
if bar = 1234567890:
print "yay you win"
foo()
#start
foo()
Ultimately my program works as it is but eventually will crash out with the recursion limit error so not ideal as I need this program to run endlessly but being a total newb to programming I am unsure how to fix it. I did try to split my program into two or three separate function rather than just the one but it was still exhibiting the recursion issue.
Thanks for any input. If anyone needs more code I can post it but thought the small piece should be sufficient to see where I am going. Any help would be appreciated.
while not (mydll.InPortB(base+1)) & 1: time.sleep(0.5)whileblock run infinitely if entered?