7
Tried using a for loop to count files... ended up crashing my whole script
I was working on a little project to rename about 300 photos in a folder. Wrote a for loop in Python that was supposed to go through them one by one, but I forgot to add a break condition when something went wrong. It got stuck in an infinite loop, filled up my entire C drive with temp files, and I had to restart my computer. Has anyone else had a simple loop blow up on them like that?
3 comments
Log in to join the discussion
Log In3 Comments
theagibson16d ago
Yeah, forgetting a break point will wreck your whole morning real quick.
8
faith_thomas16d ago
Oh man, I've been there. Made a while loop that outran my patience and my hard drive at the same time. Now I just add a counter and a print statement every ten iterations so I can watch my mistakes in real time.
5
emery_white15d ago
Oh come on, I actually feel like infinite loops get a bad rap. @faith_thomas, you ever just let one run and watch your computer slowly lose its mind just to see how far it goes? It's like a little science experiment. A little chaos builds character.
1