Name of function caller

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • HMS Surprise

    #1

    Name of function caller

    Is there a way that a function may access the doc string or func_name
    of the caller?

    Thanks,

    jvh

  • Paul McGuire

    #2
    Re: Name of function caller

    On May 15, 4:59 pm, HMS Surprise <j...@datavoice int.comwrote:
    Is there a way that a function may access the doc string or func_name
    of the caller?
    >
    Thanks,
    >
    jvh
    Yes. The inspect module allows you to look up the call stack for
    information on the caller, the caller's caller, local vars, etc.

    -- Paul

    Comment

    • HMS Surprise

      #3
      Re: Name of function caller

      On May 15, 5:13 pm, Paul McGuire <p...@austin.rr .comwrote:
      On May 15, 4:59 pm, HMS Surprise <j...@datavoice int.comwrote:
      >
      Is there a way that a function may access the doc string or func_name
      of the caller?
      >
      Thanks,
      >
      jvh
      >
      Yes. The inspect module allows you to look up the call stack for
      information on the caller, the caller's caller, local vars, etc.
      >
      -- Paul
      Thanks Paul.

      Running jython 2.2. No module named inspect or cInspect


      drat...

      Comment

      • John Machin

        #4
        Re: Name of function caller

        On May 16, 8:56 am, HMS Surprise <j...@datavoice int.comwrote:
        On May 15, 5:13 pm, Paul McGuire <p...@austin.rr .comwrote:
        >
        On May 15, 4:59 pm, HMS Surprise <j...@datavoice int.comwrote:
        >
        Is there a way that a function may access the doc string or func_name
        of the caller?
        >
        Thanks,
        >
        jvh
        >
        Yes. The inspect module allows you to look up the call stack for
        information on the caller, the caller's caller, local vars, etc.
        >
        -- Paul
        >
        Thanks Paul.
        >
        Running jython 2.2. No module named inspect or cInspect
        >
        drat...
        According to the current docs, inspect was new in Python 2.1. You've
        been in more strife than Paris Hilton recently and it's hard to keep
        track, but IIRC you're the guy with the badly-stuffed sys.path ...
        have a look on your disk(s). OTOH maybe inspect depends on the
        internal call stack implementation --- in that case you would need to
        ask on the jython mailing-list.

        HTH,
        John


        Comment

        • James Stroud

          #5
          Re: Name of function caller

          HMS Surprise wrote:
          Is there a way that a function may access the doc string or func_name
          of the caller?
          >
          Thanks,
          >
          jvh
          >
          Add a parameter to the function to avoid mutilating your code with
          implementation specific inspection:

          def fun(caller, *original_param eters):
          do_something_to _caller_without _magic(caller)
          do_something_wi th_original_par ameters(*origin al_parameters)

          James

          Comment

          Working...