Re: Error message repetition

2010-07-07 Thread Thomas Jollans
On 07/07/2010 05:10 PM, Tambet wrote:
 Hello!
 
 I have such problem that:
 
 * My console shows maximally x last lines, then truncates
 * Error message takes 2 line
 * In case of very big stack trace, there will be 2*x error lines
 * In such case I do not see any debug output
 
 In this case, it's about recursion:
 
   File b2.py, line 124, in seek_solution
 solution = self.seek_solution(weight + U.gravity, len(test), test)
   File b2.py, line 124, in seek_solution
 solution = self.seek_solution(weight + U.gravity, len(test), test)
   File b2.py, line 124, in seek_solution
 solution = self.seek_solution(weight + U.gravity, len(test), test)
   File b2.py, line 124, in seek_solution
 solution = self.seek_solution(weight + U.gravity, len(test), test)
   File b2.py, line 124, in seek_solution
 solution = self.seek_solution(weight + U.gravity, len(test), test)
   File b2.py, line 124, in seek_solution
 solution = self.seek_solution(weight + U.gravity, len(test), test)
 and so on...

Depending on how far this goes up, you might just be able to change the
backlog your terminal emulator saves? that would allow you to scroll up.
If you can't do that, you should get a proper console.

Anyway, if you want to customise the traceback output, you can!
simply replace sys.excepthook with your own version.

http://docs.python.org/dev/py3k/library/sys.html#sys.excepthook

 
 I think it should be instead:
   File b2.py, line 124, in seek_solution [*repeated x times*]
 solution = self.seek_solution(weight + U.gravity, len(test), test)
 
 Getting big strack trace is most probable with functions calling
 themselves - thus, long stack traces usually contain such repetitions.
 
 As those functions might not call themselves directly, one cycle of
 recursion might become four lines long, in such case:
 
 Stack item 1:  File b2.py, line 124, in seek_solution
 solution = self.seek_solution(weight + U.gravity, len(test), test)
 Stack item 2:  File b2.py, line 124, in seek_solution
 solution = self.seek_solution(weight + U.gravity, len(test), test)
 Stack item repetitions: [#1, #2] * x
 
 This could simply enumerate stack items and then create formulas of
 repetitions, like:
 [[#1, #2] * 15, #3 * 15] * 3
 
 If it shows each message written-out at least one and max two or three
 times, but over that gives it an id and shows patterns of those instead,
 it will be a lot better. I have, sometimes, gone through some four pages
 of Java stack traces etc., but I think that having such long array of
 errors does not make it more readable or simple - if you can see
 everything in one page, then it's good enough for pondering. And
 scrolling up and looking at output would be a nice feature ;) Especially
 now, as I am going to raise recursion limit - this program would be
 perfectly possible without relying on built-in loop constructions so
 much, but I did it yesterday in such manner and it simply raised into
 unmanageable complexity. Thus, now I am trying to encapsulate it's logic
 into pieces, which maximize the use of Pythons overloads and
 function-based iterators etc., but this makes error messages that long
 when I do something wrong - and I can't even check if that was really
 some mistake in code or just the recursion actually needs to be deeper
 than I hoped.
 
 Tambet
 

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error message repetition

2010-07-07 Thread Tambet
 Depending on how far this goes up, you might just be able to change the
 backlog your terminal emulator saves? that would allow you to scroll up.
 If you can't do that, you should get a proper console.


I use bash, which allows to do that. This was rather a case example -
actually this output gets pretty annoying anyway and should contain only
most important information at any given moment. Scrollbar getting too small
is another example of the same case ...the case that if something outputs
2000 lines of repetition, it's not very much of use. This could be that
someone does not understand the cryptic output, but I think that anyone
having that long traceback is probably intelligent enough to google for
Python traceback what those cryptic things mean ;) I think that this
functionality should be triggered only by traceback bigger than, say, 20
lines or so. Also, this is not the point, where processor usage costs
anything.

Anyway, if you want to customise the traceback output, you can!
 simply replace sys.excepthook with your own version.

 http://docs.python.org/dev/py3k/library/sys.html#sys.excepthook


Ok, I should have thought of that - anyway, such thing should be standard
functionality. I personally love nonverbose output - if it can't say it in 1
A4, it should just tell me that it could if I asked. I mean, normally I like
to have one sight over the traceback and another over program itself.

Thanks for that hook ...I will use it in case I get four of five more
similar errors today ;)
-- 
http://mail.python.org/mailman/listinfo/python-list