Skip to content

request access to __file__ and __line__ perhaps via inspect.getframeinfo? #1054

@larryfast

Description

@larryfast

I want to add fname & lineno to my diagnostic messages. In normal python stackoverflow suggests I use the following: https://stackoverflow.com/questions/3711184/how-to-use-inspect-to-get-the-callers-info-from-callee-in-python
previous_frame = inspect.currentframe().f_back
(filename, line_number, function_name, lines, index) = inspect.getframeinfo(previous_frame)
return (filename, line_number, function_name, lines, index)

Original request posted in CircuitPython forum where tannewt2 wrote:
I don't think we expose that data yet. We do store it though. Please file a GitHub issue with how its done in CPython and hopefully someone will add it.

https://forums.adafruit.com/posting.php?mode=reply&f=60&t=138518

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions