First time caller. Fairly new to Python. Warning! Portions of this are not very 'pythonic'.
The following psedo-code is structurally very similar to a program that I am writing.
Code: Select all
def Do_Weird_Stuff():
print(' '); #<- this is the interesting part
return [51.60709 995.4415 237.2677 685.4344 36.96526 259.2582]
def Calc():
while True
bCals = Do_Weird_Stuff();
if (bCals[0] == some_value):
return bCalcs;
def main():
print('main() - Start!')
for i in range(3):
LED_on();
pyb.delay(500);
bResult = Calc()
print(bResult, ' Iteration: ', i);
LED_off();
pyb.delay(500);
print('Exiting...');
I expect the following output from the program:
main() - Start!
51.60709 995.4415 237.2677 685.4344 36.96526 259.2582 Iteration: 1
51.60709 995.4415 237.2677 685.4344 36.96526 259.2582 Iteration: 2
51.60709 995.4415 237.2677 685.4344 36.96526 259.2582 Iteration: 3
Exiting...
The program does not do that. It lists the following:
Part 1.
main() - Start!
Part 2.
---> At this point, the output from the program has stopped and lands at an rshell prompt.
---> So, I type in 'repl' on the rshell command line and get the following:
Part 3. The rest of the output displays.
51.60709 995.4415 237.2677 685.4344 36.96526 259.2582 Iteration: 1
51.60709 995.4415 237.2677 685.4344 36.96526 259.2582 Iteration: 2
51.60709 995.4415 237.2677 685.4344 36.96526 259.2582 Iteration: 3
Exiting...
There are two interesting things about this.
- 1. The program exits very quickly to rshell; but, I can tell the program is still executing because the LED continues to blink.
As soon as I run repl from the rshell command line, the rest of the output is displayed.
I can not figure out why this happens.
2. I can force a change in the behavior of the output if I put a print() statement in the Do_Weird_Stuff() routine.
(See above) As soon as I put in the print() statement in Do_Weird_Stuff(), the program displays as expected; but,
with an extra print().
Any thoughts as to what is going on?
Thanks