Funny Python error messages

Discussion in 'Python' started by Will Stuyvesant, Jan 21, 2005.

  1. 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
    Will Stuyvesant, Jan 21, 2005
    #1
    1. Advertising

  2. Will Stuyvesant

    Peter Hansen Guest

    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
    Peter Hansen, Jan 21, 2005
    #2
    1. Advertising

  3. 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>
    Fredrik Lundh, Jan 21, 2005
    #3
  4. Will Stuyvesant

    Carl Banks Guest

    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
    Carl Banks, Jan 21, 2005
    #4
  5. Will Stuyvesant

    Hans Nowak Guest

    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/
    Hans Nowak, Jan 21, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2hyaXMgTG92ZQ==?=

    Funny Error

    =?Utf-8?B?Q2hyaXMgTG92ZQ==?=, Dec 17, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    5,652
    exelio
    Oct 24, 2006
  2. Guyon Morée
    Replies:
    4
    Views:
    322
    Irmen de Jong
    Jul 30, 2003
  3. Replies:
    8
    Views:
    339
  4. Breal
    Replies:
    3
    Views:
    341
    Ben Finney
    Dec 18, 2007
  5. Nasser M. Abbasi
    Replies:
    6
    Views:
    533
    Lawrence D'Oliveiro
    May 23, 2011
Loading...

Share This Page