How to get the method/function which called a function?

Alessandro Iob alessandro.iob at dlevel.com
Wed Jul 24 11:31:51 EDT 2002


Example:

def log(msg):
	caller = GET_CALLER()
	print repr(caller), msg

class A:
	def t(self):
		log('a message')

a = A()
a.t() # prints "<bound method A.t of <__main__.A instance at 0x805bb64>>
a message"

How can I implement the "GET_CALLER()" function in "log()" ?

Thanx

-- 
Alessandro Iob <alessandro.iob at dlevel.com>
D-Level srl, via Cavour 78, 33050 Rivignano UD ITALY 
Tel: +39 0432 773785, Fax: +39 0432 774217
WWW: http://www.dlevel.com , E-Mail: info at dlevel.com


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 240 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20020724/177fec7b/attachment.sig>


More information about the Python-list mailing list