By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

Funny Python error messages

P: n/a

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

Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Jul 18 '05 #2

P: n/a
Peter Hansen wrote:
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.


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>

Jul 18 '05 #3

P: n/a

Peter Hansen wrote:
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.


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.

--
CARL BANKS

Jul 18 '05 #4

P: n/a
Will Stuyvesant wrote:
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

--
Hans Nowak
http://zephyrfalcon.org/

Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.