get line number and filename in a source file
Chris Rebert
clp2 at rebertia.com
Wed Nov 25 01:01:57 EST 2009
On Tue, Nov 24, 2009 at 9:47 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
> __LINE__ __FILE__ in C++ can give the current line number and
> filename. Is there a similar thing in python that can give me the
> current line number and filename?
import inspect
filename, linenum, funcname = inspect.getframeinfo(inspect.currentframe())[:3]
Cheers,
Chris
--
http://blog.rebertia.com
More information about the Python-list
mailing list