Funny Python error messages

Peter Hansen peter at engcorp.com
Fri Jan 21 09:16:51 EST 2005


Will Stuyvesant wrote:
> Perhaps this will even be a useful thread, to brighten the
> life of the brave people doing the hard work of providing us
> with error messages.
> 
> My first one (i'm learning, i'm learning) is
> 
> TypeError: 'callable-iterator' object is not callable
> 
> # >>> it = iter(lambda:0, 0)
> # >>> it()
> # TypeError: 'callable-iterator' object is not callable

Given that the supposed humour depends on the *name* of
the object, which is "callable-iterator", I'd say it's
probably not hard to come up with lots of "funny" error
messages this way.

For example:

 >>> def a():
...  print is_not
...  is_not = 0
...
 >>> a()
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "<stdin>", line 2, in a
UnboundLocalError: local variable 'is_not' referenced before assignment

My funny bone must be broken today, though, because I don't
see these as very funny...

(Did you understand *why* you got your error?
You don't call iterators, you call .next() on them...)

-Peter



More information about the Python-list mailing list