C API -- Two questions

beginner zyzhu2000 at gmail.com
Fri Jul 27 02:34:22 CEST 2007


Hi Everyone,

I am writing a C extension and encountered two problems.

1) How can I include a description of the arguments? I can include a
description string. No problem. But whenever I say help(my_func) it
shows the arguments are "... ". However, if a function is defined in
python, I will definitely be able to see the parameters when I type
help(my_func).

2) How can I make the arguments less picky without writing a lot of
type conversion code? My function really needs a tuple as its
argument. For example, f( (1,2,3) ) would work. However, in order to
make it easy to use, I am thinking that it should be able to take a
list too. In other words, I want f( [1,2,3] ) to work also. I can
certainly check for the types in the code and deal with each
situation. But remember this is tedious to do in C. Is there any
better way to handle this?

Thanks,
cg




More information about the Python-list mailing list