L
5

Accidentally found a debug trick that saved me 3 hours at the library computer lab

I was at the public library last Thursday working on this Python script for a class project. Kept getting this weird index error I couldn't figure out for like an hour. Then I accidentally hit print on a variable I was sure was working and found out it was returning None instead of the list I expected. Turns out I had a function that wasn't returning anything cause I forgot the return statement. That single print() call saved me from rewriting the whole thing. Has anyone else found a simple print statement or log that fixed their whole bug?
2 comments

Log in to join the discussion

Log In
2 Comments
reese_fox
reese_fox5d ago
Print statements are basic debugging, not some secret hack.
2
stella279
stella2795d ago
wait but is that actually always true though @reese_fox? i mean yeah it's a basic tool but lots of people don't realize how powerful it can be for learning the flow of code step by step. sometimes you need to see the exact values at each point to really understand what's happening under the hood. even experienced devs use it when things get confusing with nested loops or async stuff. i think writing it off as just "basic" kinda misses how useful it can be for teaching yourself new concepts lol. not saying it's a secret hack or anything but it's way more than just throwing in a few prints and calling it done.
5