O
17

Found out Python's 'is' vs '==' thing cost me 3 hours last night

I was comparing two lists that looked identical but kept getting False. Turns out 'is' checks if they're the same object in memory (not if they have the same values). Found this in a beginner's Python guide on Real Python's site - wish I'd read it before my debugging session. Anyone else trip over this when they started out?
2 comments

Log in to join the discussion

Log In
2 Comments
joel603
joel60329d ago
So did you fix it by just switching to double equals?
2
matthewkim
matthewkim28d ago
Nah man, triple equals all the way, that's where the real bugs hide.
4