Why not just show the out-of-range index?

T

Tim Chase

- because error messages are not debugging tools (better use unit
Then what are they? Machine-generated poetry?
>>> me.__cmp__(gruntbuggly['freddled'].micturations,
bee[LURGID].gabbleblotchits[PLURDLED]) == 0

Traceback (most recent call last):
File "<stdin>", line 1, in ?
VogonPoetryException: Bleem miserable venchit! Bleem forever
mestinglish asunder frapt!


Nah...Exceptions aren't poetry...they're programmer insults akin
to "You fool! How could you have let this happen!" And if
things are really bad, exceptions call you "silly" :*)

-tkc
 
I

Istvan Albert

Russ said:
The message tells you where the error occurred, but it doesn't tell you
what the range and the offending index are.

So here is a scenario,

what should happen if by accident one uses a 50Mb string as an index?
Should it be displayed?

i.
 
N

Neil Cerutti

- because error messages are not debugging tools (better use unit

Then what are they? Machine-generated poetry?
me.__cmp__(gruntbuggly['freddled'].micturations,
bee[LURGID].gabbleblotchits[PLURDLED]) == 0

Traceback (most recent call last):
File "<stdin>", line 1, in ?
VogonPoetryException: Bleem miserable venchit! Bleem forever
mestinglish asunder frapt!

You should warn people before posting something that dangerous. I
would at least have had time to pull the babelfish out of my ear,
and so I could have avoided the nosebleed.
 
O

OKB (not okblacke)

John said:
It should be extremely easy (rather than "not impossible") for
anybody with half a clue
Sheesh.
And despite your use of RHN (Reverse Hungarian Notation) you don't
know that someList is a list?

I appreciate your taking the time to post this thoughtful and civil
reply not once but six times.

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
 
J

John Machin

OKB said:
I appreciate your taking the time to post this thoughtful and civil
reply not once but six times.

You should direct your appreciation to Google Groups for 5 out of the 6
times -- it was stating incorrectly that it had not posted due to a 502
error; I have since removed those.

Yes, it was thoughtful and civil compared to some earlier postings in
this thread, wasn't it?

I do hope that you didn't confuse (your interpretation of) the manner
with the message: again, extremely high cost-to-benefit ratio.

Cheers,
John
 
H

Hendrik van Rooyen

what should happen if by accident one uses a 50Mb string as an index?
Should it be displayed?

It is my opinion that yes, the first 40Mb or so should be displayed, as a lesson
to the perpetrator, and to help him find the error.

Displaying 50 Mb is obviously ridiculous.

- Hendrik
 
R

Roberto Bonvallet

OKB (not okblacke) said:
Can you give a real example from your code where the location of
such a human error (you cause a variable to bound to a value of
inappropriate type) would be difficult to find, plus an estimate of
how often you would make such an error?

Here is an example:

self.outFile.write(str(len(self.hits)) + ' in ' + searchInfo.recordName
+ '\t' + ']['.join((a. group() for a in self.hits)) + '\n')

This is from a text-searching tool I have written to search
linguistic corpora. This statement writes a summary line to the output
file indicating how many hits were found in that file. [...]
The problem in this line was that I'd forgotten to put str() around
the len(). [...]

For printing formatted string, the best way to avoid such errors is using
the sprintf-like Python string formatting:

self.outFile.write("%d in %s\t%s\n" % (
len(self.hits),
searchInfo.recordName,
']['.join(a.group() for a in self.hits)))
 

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,774
Messages
2,569,598
Members
45,161
Latest member
GertrudeMa
Top