blog.errorhelp.com - Musings and announcements regarding the bug.gd ErrorHelp search engine.

error_help() for Python hackers

In the last days before Pycon08 we hastily scripted support for error sharing (based on bug.gd) for use inside the Python interpreter. This is a bit of a hint of some of our long-term plans with our technology. You should give it a whirl and let us know what you think.

Install

It’s in the Python Cheese Shop, so you can install it pretty easily:

easy_install bug.gd

(If you don’t have easy_install, you really should get it.)

After finishing the installation steps (it requires you to run error_help_config.py from your scripts directory), the error_help tool is now accessible from the interactive interpreter whenever you need.

Using error_help()

Whenever you run into an exception in the interactive interpreter, you can type error_help() and you’ll find everyone else who ran into that same error and (hopefully) how they solved it.

Here’s an example session:

>>> 0/0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero
>>> error_help()
========== 1 of 8 ==========
Error: Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: integer division or modulo by zero

Solution: I divided by zero as a test. Maybe you did the same thing?
The trick is not to divide by zero!
========== 2 of 8 ==========
Error: Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named shinynewmodule

Solution: (Example error and solutions)
I didn't have the shinynewmodule installed.
You can install it via fake_easy_install shinynewmodule

As people use this feature, in a couple of days, they’ll receive email asking how they worked around the error. Their solution will then be visible for every future Pythonista that runs into the problem. If everyone gives back to the community, mysterious errors will be a thing of the past.

If you wanted to see some of the other results from the search, for example the 7th result, you’d just use:

error_help(7)

Anyway, we’ve love to hear your feedback on this quick proof of concept. Keep your eye out for more “formal” versions of this feature in other applications.

ErrorHelp is the most popular search engine for error messages.
Share solutions so nobody has to waste time researching later. Be part of the solution.

6 Responses to “error_help() for Python hackers”

  1. Denis Says:

    I test with zero division independently of your sample, and cant imagine another bug for test.
    Uninstalling error_help()….

  2. Tomas Says:

    Excellent initiative!

    Can’t wait to see it expanded upon and implemented in a more rich way (i.e integrated into ide’s, and connected to a website for online browsing and moderation of solutions etc)

  3. matthew Says:

    Hey Tomas— Glad you like the idea! Those suggestions are part of our plans (and some already exist on bug.gd). This module uses that bug.gd website backend which allows error searching, rating, and commenting.

    More general background:
    http://bug.gd/search/faq/

  4. Thomas Says:

    [...]I love integration (especially Web2.0 style integration and sharing) and this is a fine example. What other language gets you user generated error solutions & content from the prompt / IDE![...]

    (Awesome work btw)

  5. Tom Leys Says:

    This is a great idea!

    I just started working with Python (more a C++ programmer) and spent ages recently trying to figure out why I was having trouble in a function with a class instance method I was trying to call - It turns out that the caller had passed me the class name not the class instance i.e MyClass rather than MyClass()

    I would have saved so much time.

    -Tom

  6. J Meier Says:

    This will encourage a sloppy, recipe-based approach to programming problems, rather than analysis and understanding. This will only cause more, worse bugs later as these programmers write themselves into situations they haven’t learned the background or discipline to handle. While useful for application users facing meaningless error messages, this is poison to a programming environment. Fail.

Leave a Reply