On Sun, May 13, 2018 at 02:42:48PM +1000, Chris Angelico wrote: > On Sun, May 13, 2018 at 2:31 PM, Python <pyt...@bladeshadow.org> wrote: > >> Yes, and I'd go further: I *am* too stupid to get this right. > > > > No, you are not. Do you ever say "dog" when you mean "dot" instead? > > Do you ever say "dad" when you mean "mom" instead? Internalize that > > "=" is "equals" (or "assigns" if you prefer) and "==" is "is equal to" > > then use those phrases in your head when you're thinking about which > > one you need in your code, and I'm pretty sure you'll stop making this > > mistake. It may help that the phrase with twice as many syllables > > represents the operator that has twice as many characters. Eventually > > it becomes second nature, like not calling Dad "Mom." > > Riiiight, of course. Because prevention of bugs is just a matter of > wanting to.
Preventing *certain classes* of bugs, mainly botching syntax, is mostly just a matter of wanting to, like a piano virtuoso who can play complicated pieces night after night flawlessly. It just takes focus and practice. Preventing the = vs. == bug is nowhere near as complex or difficut as La Campanella, so you don't even need to be a virtuoso. You just have to be mindful and careful. -- https://mail.python.org/mailman/listinfo/python-list