My most common Python mistake

Posted by Martin Vilcans on 15 May 2007

For some reason I make this specific error all the time:

if len(sys.argv != 2):
    print "Usage: %s <input file>" % sys.argv[0]
    sys.exit(1)

Can you spot it? It gives the runtime error "object of type 'bool' has no len()". I guess I'm too used to languages that require parentheses around the expression in an if statement.

Previous: Short film “På tåget” now online
Next: Kos Conference

Comments disabled on this post.