Getting parameters in a walkback

Fearless Freep joconnor at cybermesa.com
Thu Sep 5 11:34:30 EDT 2002


I was banging around with traceback and trying to drill down into
frame objects and such and I'm kinda stuck.

What I'd like to do is find out if, when an Exeption is raised in a
method or function, is it possible to get the values of the parameters
that were passed in?  Something like...

def divide (x,y):
    return x / y


def divideTwoNumbers (a,b):
    return divide (a,b)


try: 
    divideTwoNumbers (1,0)

except:
   # now what?

This is kinda a contrived example just to show calling a function that
calls a function that will raise an exception back out to the top
level.  I can determine in the except: block that a divide by zero
error was raised in devide(), but can I determine what the values for
the two parameters (x and y) were?

Like I said, a contrived example, but it could help in debugging
larger systems if, for example, I tried to write to a file and the
file didn't exist or something

Thanks

Take care,
Jay



More information about the Python-list mailing list