473,323 Members | 1,550 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Any easy way to get more RE-friendly error messages from Python?

I'm setting myself up to use Python with jEdit (after trying
jed, VIM, others...urggh.) One small problem I'm having is
that while jEdit has a nice plugin called Console which can
be set up to run python scripts, and parse the result for
errors which can then be used to put the editing cursor
directly on the offending line, it doesn't play so well with
the multiline error messages that Python generates. (Actually,
I've never liked them a lot myself :-) ) The easiest way
to deal with this is probably to hack Python to put out
its error messages in a different format: I can think of
a couple of approaches, but they seem a little kludgey,
so I thought I'd solicit suggestions from the group.

So instead of error output that looks like this:

Traceback (most recent call last):
File "__init__.py", line 75, in ?
DNOTE('''This documentation was writting using the 'doco' module.'''),
NameError: name 'DNOTE' is not defined

I'd prefer something like:

PyError:__init__.py:75:NameError: name 'DNOTE' is not defined

(with, obviously, one such line for each element of the traceback.)
The thoughts that come to me first are:

1) Write some sort of wrapper to python.
2) Find and change an internal python hook.

I'm wondering what other ways of approaching this might
be suggested--both of the above have certain elements
I dislike.
Thanks,
Ken
Jul 18 '05 #1
1 1561
Kenneth McDonald wrote:
Traceback (most recent call last):
File "__init__.py", line 75, in ?
DNOTE('''This documentation was writting using the 'doco' module.'''),
NameError: name 'DNOTE' is not defined

I'd prefer something like:
PyError:__init__.py:75:NameError: name 'DNOTE' is not defined

The thoughts that come to me first are:
2) Find and change an internal python hook.


sys.excepthook() is your friend here. See the module docs
for 'sys'. You could install it "globally" using a sitecustomize.py
file, most likely. (Check the site.py docs or source for more on that.)

Also check the source for traceback.py and see how it
formats stuff now. You can easily write your own formatter
that does things differently.

You might also check the source for Zope (or was it Twisted?
sorry, can't recall... maybe it was both!) which has a one-line
exception formatter somewhere, for log files, as I recall.

-Peter
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: JW | last post by:
I'm displaying product thumbnails with brief descriptions on web pages. Clicking on the product does a javascript popup with larger image and detailed description info passed to the javascript...
6
by: Nick Dreyer | last post by:
In VB.NET I would like to not have to create property get/set procedures for every class variable I want to expose to Excel VBA projects in COM builds. Can anyone tell me if that is possible, or...
3
by: Oliver Bryant | last post by:
I just finished developing a javascipt component allowing floating captions to appear over HTML elements. If anyone wants to check it out you can see specs and download it from...
16
by: Terry McNamee | last post by:
return arr.Length == 0 ? null : arr.ToString(); Can anyone tell me what this syntax means? Does it basically mean if arr.Length is equal to 0 then return null, else return the item in the...
2
by: Thomas | last post by:
Hi, I there anybody here that are designing applications with asp.net without html in aspx files? The problem is that aspx files is a dependency, and I would like to avoid having that...
5
by: LedZep | last post by:
What up, All I need to do is enter a last name in a text box, query a MSAccess database and display the name with the corresponding columns. This is no problem, but when there are more than one...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
4
by: n | last post by:
Hello! Here is a problem I hope you can point me to a solution. It Problem: A teacher needs to know which lesson to teach. A school has a curriculum with 26 lessons, A-Z. For a given class,...
25
by: Andy B | last post by:
How hard/easy is it to use/learn VB compared to c#?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.