C-API: Extract information from function object

Discussion in 'Python' started by moerchendiser2k3, Mar 24, 2010.

  1. Hi,

    I have a reference to a function and would like to know how to extract
    information from a function object.

    Information I am looking for: line and file where this function is
    from.

    PyObject_Call can do this to when I call a function object and
    something failed so these information are written to the traceback. So
    any suggestions how to do that?

    Thx!! moerchendiser2k3
    moerchendiser2k3, Mar 24, 2010
    #1
    1. Advertising

  2. En Wed, 24 Mar 2010 12:09:27 -0300, moerchendiser2k3
    <> escribió:

    > I have a reference to a function and would like to know how to extract
    > information from a function object.
    >
    > Information I am looking for: line and file where this function is
    > from.
    >
    > PyObject_Call can do this to when I call a function object and
    > something failed so these information are written to the traceback. So
    > any suggestions how to do that?


    See the Language Reference; the associated code object holds the file and
    starting line the function comes from.
    The traceback object contains better information (like the line being
    executed instead of the first one). Why don't you use it instead?

    --
    Gabriel Genellina
    Gabriel Genellina, Mar 24, 2010
    #2
    1. Advertising

  3. Gabriel Genellina, 24.03.2010 17:49:
    > En Wed, 24 Mar 2010 12:09:27 -0300, moerchendiser2k3 escribió:
    >
    >> I have a reference to a function and would like to know how to extract
    >> information from a function object.
    >>
    >> Information I am looking for: line and file where this function is
    >> from.
    >>
    >> PyObject_Call can do this to when I call a function object and
    >> something failed so these information are written to the traceback. So
    >> any suggestions how to do that?

    >
    > See the Language Reference; the associated code object holds the file
    > and starting line the function comes from.
    > The traceback object contains better information (like the line being
    > executed instead of the first one). Why don't you use it instead?


    Note that this was a follow-up to another recent thread where I managed to
    extract the details from the OP by stoically asking back, especially the
    information that this is not about exception handling but rather about
    reporting incorrect return values.

    This is a good example when you need a reason why not to split threads on
    the same subject...

    Stefan
    Stefan Behnel, Mar 25, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Adams
    Replies:
    3
    Views:
    5,457
    GeorgeL
    Jul 16, 2007
  2. Ulysse
    Replies:
    7
    Views:
    432
    Ulysse
    Apr 2, 2007
  3. Jackie Wang

    Extract Information from Tables in html

    Jackie Wang, Sep 5, 2008, in forum: Python
    Replies:
    1
    Views:
    289
    Stefan Behnel
    Sep 5, 2008
  4. Stefan Istrate
    Replies:
    8
    Views:
    293
    Arne Vajhøj
    Apr 9, 2009
  5. Imaginationworks
    Replies:
    7
    Views:
    969
    Paul McGuire
    Feb 18, 2010
Loading...

Share This Page