call static function from extension module - syntaxerror

Erik Max Francis max at alcyone.com
Fri Dec 23 01:12:45 EST 2005


Todd wrote:

> I'm working right from the example here to make a basic extenstion
> module.
> http://docs.python.org/ext/intro.html
> http://www.dalkescientific.com/writings/diary/archive/2005/04/26/extending_python.html
> 
> I can load my module into python and dir shows my function.  But I get
> a syntax error if I try to access it.
> 
>>>> ast_man.exec
>   File "<stdin>", line 1
>     ast_man.exec
>                ^
> SyntaxError: invalid syntax
> 
> However, I can get at it using getattr.  I tried compiling myself and
> using setup.  My method is defined as
> 
> static PyMethodDef ast_man_methods[] = {
>     {"exec",exec,METH_VARARGS,"Execute Asterisk commands."},
>     {NULL,NULL,0,NULL}
> };
> 
> What might be my problem??

exec is a reserved word.

 >>> exec 'print 1'
1
 >>> exec = 1
   File "<stdin>", line 1
     exec = 1
          ^
SyntaxError: invalid syntax

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   We have lingered long enough on the shores of the cosmic ocean.
   -- Carl Sagan, 1934-1996



More information about the Python-list mailing list