Le dimanche 13 août 2006 14:18, John Machin a écrit :
I don't usually go for one-liners, especially ugly ones like
"inspect.stack( )[1][1:3]" but it avoids the risk of hanging on to a
reference to the frame object -- see the warning in the inspect docs.
"inspect.stack( )[1][1:3]" but it avoids the risk of hanging on to a
reference to the frame object -- see the warning in the inspect docs.
more accurate :
import inspect
try :
c=inspect.curre ntframe()
log_msg(c.f_lin eno, c.f_code.co_fil ename)
finally :
del c
or shorter ;
from inspect import currentframe
log_msg(current frame().f_linen o,
currentframe(). f_code.co_filen ame)
--
_____________
Maric Michaud
_____________
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
Leave a comment: