get line number

Sean Ross sross at connectmail.carleton.ca
Tue Aug 12 09:46:14 EDT 2003


"Richard Mertens" <richard.mertens at wolfi.org> wrote in message
news:Xns93D5944E0F172richardmertenswolfio at 130.133.1.4...
> How do get the actual line number from the actual running sourcecode.
> I need it for debugging purpose
>

Use the inspect module:

1    import inspect
2    print inspect.getlineno(inspect.currentframe())
3    print inspect.getlineno(inspect.currentframe())
4


# output
2
3






More information about the Python-list mailing list