type lookuperror

Gene Heskett gheskett at shentel.net
Thu Aug 18 10:02:31 EDT 2016


On Thursday 18 August 2016 07:28:06 Chris Angelico wrote:

> On Thu, Aug 18, 2016 at 7:55 PM, meInvent bbird <jobmattcon at gmail.com> 
wrote:
> > actually i would like to remove try except code in all function
> >
> > and i feel that try except code for a large block code can not
> > show which function name , which line number error,
> > if use try except for specified code block to show where it has
> > error it will have many ugly try except code and need many human
> > force to craft the code, i hope that code write once for program to
> > program itself in future.
> >
> > actually this method i ask is not good enough since it will need
> > to add many function wrapper.
>
> You can't get a program to program itself. That's called the
> Singularity [1], and depending on your point of view, it's either
> still in the future, or fundamentally impossible. In any case,
> computers today cannot program themselves.

That is a pretty broad statement to make, considering I have actually 
done it. On an RCA 1802 based (Cosmac Super Elf) computer. Every byte of 
static ram memory in those days (1978) was precious, (4k board kit was 
$250) so rather than having 30 nearly identical copies of a subroutine 
each doing a similar job but with different data, I actually overwrote 3 
or 4 bytes of a single subroutine to change what it did according to 
where it was in the main loop.  So when it was done with that pass, it 
put the original bytes back. Controlling a videotape machine at a tv 
station in northern kalipornia, it was dead stable, running from power 
failure to power failure.  And, I checked about 15 years later, and it 
was still in 10+ times a day use.  If memory was that precious today, it 
would still be a valid method to shrink a complex program.

> So what exactly is it you're wanting? When an exception happens, the
> entire traceback is recorded, and unless you're throwing that away,
> it'll be shown to you. Just let the exception bubble all the way up to
> top level, and then read the traceback. Some IDEs can even help you
> step through the code to see context for each line of traceback;
> ipython is also pretty helpful with reading tracebacks. I advise
> getting to know the tools you have available, rather than trying to
> reinvent the wheel.

Re-inventing the wheel is not required when all it needs is a new valve 
stem.

> ChrisA
>
> [1] https://en.wikipedia.org/wiki/Technological_singularity


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>



More information about the Python-list mailing list