Getting the line number of the definition of a function

Does inspect.getsourceline do what you are after?

>>> import inspect
>>> from pathlib import PosixPath
>>>> inspect.getsourcelines(PosixPath)[1]
1538
>>>> inspect.getsourcelines(PosixPath.glob)[1]
1121

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top