Misleading error message of the day
Roy Smith
roy at panix.com
Thu Dec 8 13:42:45 EST 2011
(some,
very,
long,
list,
of,
variable,
names,
to,
get,
the,
stuff,
unpacked,
into) = function_that_should_return_a_14_tuple()
raises
ValueError: too many values to unpack
Quick, what's the bug? Did I forget a variable on the LHS, or is my function returning more things than it should? I know it's supposed to be 14, but I don't know which side is wrong. Had it said "... expected 13, got 14", I would know immediately.
Error messages should be as explicit as possible. It's just like bug reports. The basic mantra of a bug report is:
1) This is what I did
2) This is what I expected to happen
3) This is what I observed happen
4) This is how what I observed differed from what I expected
Saying, "expected X, got Y" is more explicit than "got too many"
More information about the Python-list
mailing list