Funny Python error messages

W

Will Stuyvesant

Add your funny or surprising Python error messages to this
thread. A requirement is that you should also show
(minimal) code that produces the message. Put the code
below, so people can think about how to generate the message
first, a little puzzle if you like.

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
 
P

Peter Hansen

Will said:
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:
.... print is_not
.... is_not = 0
....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
 
F

Fredrik Lundh

Peter said:
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.

note that will didn't name the type himself. someone callously thought it would
be a cool idea to have a non-callable type called callable in python, rather than,
say, call it "iterator-that-dances-with-callables".

</F>
 
C

Carl Banks

Peter said:
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.

The mildly amusing nature of this error message is due to Will's
finding a name, "callable-iterator" (where callable is a name, not a
description), appearing in a different context from where it was coined
that causes us to parse it differently (where callable is a
description, not a name), and accidentally stating an absurdity.
I'd say it's actually a nice bit of subtlety.
 
H

Hans Nowak

Will said:
Add your funny or surprising Python error messages to this
thread. A requirement is that you should also show
(minimal) code that produces the message. Put the code
below, so people can think about how to generate the message
first, a little puzzle if you like.

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.

I always liked:

ValueError: insecure string pickle

This error message is not strange if you think of "insecure", "string"
and "pickle" as programming terms, but it's hugely mystifying to someone
who isn't a programmer, since all of these words have different meanings
in real life.

Some code to produce it:
>>> import cPickle
>>> x = cPickle.dumps([1,2,3,"ratsj"])
>>> y = x[:18] + "?" + x[18:]
>>> cPickle.loads(y)
Traceback (most recent call last):
File "<input>", line 1, in ?
ValueError: insecure string pickle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top