Here is one way to do it, based on this Python Cookbook recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66062
def debug(msg):
import sys
frame = sys._getframe(1) name = frame.f_code.co_name
line_number = frame.f_lineno
filename = frame.f_code.co_filenamereturn 'File "%s", line %d, in %s: %s' % (filename, line_number, name, msg)
def test(): print debug("Invalid arguments")
test()
Kent
Mohamed Lrhazi wrote:
Hello all,
In php one can produce nice debugging and logging use code like: print __FUNCTION__ . ": Invalid arguments\n";
__FUNCTION__ will be replaced by the name of the function to which that line belongs, same with __LINE__ and __FILE__ I believe.
How do I get the current method's name? and class?
Thanks.
Mohamed~ _______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor
