A Python coding mistake

June 5, 2006

There is a world of difference between '"string" in txt' and just '"string"'. It doesn't even really jump out as visually wrong to me if it's in a large if condition, which probably means the condition is big enough that it should be reorganized so that errors are more obvious, or at least harder to make.

(Repetitive code is especially prone to this sort of slip-up for me. Unfortunately, one of my bad coding habits is quietly growing into such code by accident.)

Interestingly enough, pychecker doesn't produce any warnings for this. This isn't its fault as such; although it tries to look for them, it works from the compiled bytecodes and since Python 2.3, the bytecode compiler optimizes away the constant conditions.

Pylint didn't detect it either, although it complained about a lot of other things by default (enough that I can't imagine using it on a real project, especially since I use tabs for indentation).

(This exact mistake accidentally shut down commenting here for about half a day. My apologies to anyone caught in the accident, which would have given peculiar error messages.)

Written on 05 June 2006.
« People are ordinary
Internet Distance (In Memoriam) »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Mon Jun 5 16:50:51 2006
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.