Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: How to list the global functions from a C program

Reply
Thread Tools

Re: How to list the global functions from a C program

 
 
Jack Diederich
Guest
Posts: n/a
 
      01-14-2005
On Fri, Jan 14, 2005 at 04:01:13PM +0100, Francesco Montorsi wrote:
<snip>
> PyObject *list = PyObject_Dir(m_pGlobals);
> if (!list || PyList_Check(list) == FALSE)
> return;
>
> for (int i=0,max=PyList_Size(list); i<max; i++) {
>
> PyObject *elem = PyList_GetItem(list, i);
> if (PyCallable_Check(elem) != 0) {
>
> /* this should be a function.. */
> /* HERE IS THE PROBLEM: this code is never reached */
> PyObject *str = PyObject_GetAttrString(elem, "func_name");
> }
> }
> ==============================================
>
> Everything seems to work but then when scanning the list returned
> by PyObject_Dir() I never find any callable object....
> what am I doing wrong ?


You are checking the list of strings returned from the dir() to
see if any of them are callable (they aren't). You mean to check
the thing that the string is a name for, so instead of

# callable(name)
PyCallable_Check(elem)

use

# callable(globals()[name])
PyCallable_Check(PyDict_GetItem(m_pGlobals, elem))

-Jack

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Are global functions methods of the global object? User1014 Javascript 3 12-01-2006 01:02 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 1 10-25-2006 06:50 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 0 10-25-2006 01:04 PM
How to list the global functions from a C program Francesco Montorsi Python 0 01-14-2005 03:01 PM



Advertisments