type lookuperror

Chris Angelico rosuav at gmail.com
Thu Aug 18 11:10:07 EDT 2016


On Fri, Aug 19, 2016 at 12:02 AM, Gene Heskett <gheskett at shentel.net> wrote:
> 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:
>> > 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.
>>
>> 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. [chomp details]

What you described there is an example of metaprogramming. The
thoughts behind the code all existed prior to the code modifying its
own bytes in memory. It's a fancy form of the same sorts of things
that can be done with monkeypatching and similar techniques.

What the OP was looking for was "I want my program to be able to debug
itself". That means the program has to be smart enough to figure out
its own problems. Self-modifying code isn't anywhere near that level
of intelligence.

(That's not to say self-modifying code isn't impressive, in its way. I
have great respect for it. But you have to plan it out in advance,
ergo it's not having the program program itself.)

ChrisA



More information about the Python-list mailing list