finding out the calling function

F

flupke

Hi,

i have a property in a class that gets changed
and i would want to know who changes it.
Is there a way i can find out the calling function of a property?

Thanks,
Benedict
 
F

flupke

flupke said:
Hi,

i have a property in a class that gets changed
and i would want to know who changes it.
Is there a way i can find out the calling function of a property?

Thanks,
Benedict

I solved it by using
import traceback, sys
traceback.print_stack()
in the property

However, i'm not sure this is the best way.
I also tried to use the print_tb funtion from the traceback
function

traceback.print_tb(sys.last_traceback)

This produces an error
AttributeError: 'module' object has no attribute 'last_traceback'

So how can i pass a valid "traceback" object to the print_tb function
and where do i find one?

Thanks,
Benedict
 
R

Reinhold Birkenfeld

flupke said:
Hi,

i have a property in a class that gets changed
and i would want to know who changes it.
Is there a way i can find out the calling function of a property?

You're looking for sys._getframe.

Reinhold
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top