Pop return from stack?

bvdp bob at mellowood.ca
Sun Aug 15 06:41:34 CEST 2010


On Aug 14, 5:23 pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:

> This general technique is called "monkey patching".
>

New term for me :)

> > Now, if an error is encountered myerror() is called. Fine. But execution
> > resumes in func(). Not exactly what I wanted.
>
> Of course it does. Your new error handler fails to exit, so execution
> resumes like it does after any other function.

I guess I wasn't being clear. I don't want to exit in my new bit of
code. Just continue a loop (which I didn't show in the example).

> Exceptions are the standard way of doing things. That's what sys.exit()
> does -- it raises SystemExit exception.

Okay, didn't know that exit() was really an exception. Good to know.
But, like I said, I'm not looking to exit.

>
> With very few exceptions, if you're writing your own error handlers like
> this, you're doing it wrong. Your error handler throws away useful
> debugging information, and it gives you no extra information that a
> standard Python traceback couldn't give.

Yeah, but I really don't want a traceback printed out for a user just
because a file can't be found, or he's got a bad bit of syntax in his
file. So, that's why I have the specific error routine. Works fine in
the main program.

> Oh my ... I've seen people writing Java in Python, C++ in Python, Perl in
> Python, even VB in Python, but this is the first time I've meet some one
> who wants to write assembler in Python :)

Naw, I had my fun with assembler in the good old days. Never want to
write another line of it :)




More information about the Python-list mailing list