Question about maximum recursion depth #16962
Replies: 2 comments 2 replies
|
In the middle of the script you call Trying to solve this by raising the max recursion is like a band-aid for a arterial wound. It really won't help. Instead take a look at your algorithm, in your case likely across scripts. also you may have a logic & syntax error in
script_filename = f"{x}.py" # Use f-string for correct formatting
try:
with open(script_filename, "r") as f:
script_code = f.read()
exec(script_code)
print("\nCompleted script execution.")
except OSError as e: # Catch OSError instead of FileNotFoundError
print(f"Error opening script {script_filename}: {e}")
time.sleep(2) |
|
Also check if it makes sense for your case to replace |
Uh oh!
There was an error while loading. Please reload this page.
Im very new to programming with python and have an issue with my code on the RPI Pico that is supposed to control my ws2812 led strip. Down below i pasted the selector script that displays the selected mode and opens the python script. This al works fine, but if i switch between the selector.py and the other scripts a few times i get the max recursion depth error.
I know that it is possible to set the max recursion depth to a larger ammount in python, but it seems to not be possible on micropython.
Do you have any suggestions on how I can improve my code?
All reactions