Skip to main content

Diigo Home

Caller and Callee « ActiveState Code - The Diigo Meta page

code.activestate.com/...576925 - Cached - Annotated View

Benx Shen's personal annotations on this page

benxshen
Benxshen bookmarked on 2009-10-20 python tips howto
  • Recipe 576925: Caller and Callee











    A recipe to find out which function is the caller of the current function.












    Python


    1
    2
    3
    4
    5
    6
    7
    import inspect

    def callee():
    return inspect.getouterframes(inspect.currentframe())[1][1:4]

    def caller():
    return inspect.getouterframes(inspect.currentframe())[2][1:4]

This link has been bookmarked by 2 people . It was first bookmarked on 20 Oct 2009, by Benx Shen.

  • 26 Oct 09
  • 20 Oct 09
    • Recipe 576925: Caller and Callee











      A recipe to find out which function is the caller of the current function.












      Python


      1
      2
      3
      4
      5
      6
      7
      import inspect

      def callee():
      return inspect.getouterframes(inspect.currentframe())[1][1:4]

      def caller():
      return inspect.getouterframes(inspect.currentframe())[2][1:4]