privex.helpers.black_magic

This module contains somewhat risky code that uses app introspection e.g. via inspect.

Most functions / classes in this module will ONLY work on CPython (the official Python interpreter from python.org), and their functionality is not guaranteed to be stable as they interact with the interpreter to enable special functionality such as detecting the function/class/module which called your function/method.

Functions and methods in this module may be updated with breaking API changes at any time, especially if they’re needed to adjust for a change in Python itself. Please ensure that any usage of this module is properly wrapped in a try/catch block, and avoid relying on functions/methods in this module for critical functionality of your application.

Most useful functions:

  • calling_function() - Returns the name of the function/method which called your function/method

  • calling_module() - Returns the name of the module which called your function/method

  • caller_name() - Returns the fully qualified module path to the function/method/module which called your function/method

Copyright:

    +===================================================+
    |                 © 2019 Privex Inc.                |
    |               https://www.privex.io               |
    +===================================================+
    |                                                   |
    |        Originally Developed by Privex Inc.        |
    |        License: X11 / MIT                         |
    |                                                   |
    |        Core Developer(s):                         |
    |                                                   |
    |          (+)  Chris (@someguy123) [Privex]        |
    |          (+)  Kale (@kryogenic) [Privex]          |
    |                                                   |
    +===================================================+

Copyright 2019     Privex Inc.   ( https://www.privex.io )

Functions

caller_name([skip])

Get the fully qualified name of a caller in the format some.module.SomeClass.method

calling_function([skip])

Returns the name of the function which called your function/method.

calling_module([skip])

Returns the name of the module which called your function/method.

last_frames()

last_stack_frame([frame_num])