H
23

Pro tip: stop copying code from Stack Overflow without looking at the errors

I spent 4 hours last night trying to get a simple login form to work in Python Flask. Copy pasted some code from a top Stack Overflow answer and kept getting a 500 error. Turns out the answer was 3 years old and used an outdated library version. Read the error message line by line, found the deprecated function call, swapped it for the new one and it worked in 10 minutes. Any other beginners get burned by old code snippets?
2 comments

Log in to join the discussion

Log In
2 Comments
alexlewis
alexlewis1mo ago
Did you check the date on the answer" is solid advice but people miss that dates can be misleading. Old answers sometimes get updated, so the date shown might be when someone edited the formatting not when the actual code was written. I always look at the answer's edit history now or check the specific library docs to see when functions changed.
6
fiona502
fiona5021mo ago
Did you check the date on the answer before you copied it? I started doing that after I spent a whole afternoon trying to fix a CSS layout from 2018. Turns out Flexbox had a bug back then that got patched, so the workaround was actually making things worse. Now I always scroll down to see if the comments say "this stopped working in version X" before I even look at the code.
3