C API -- Two questions

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Fri Jul 27 02:23:51 EDT 2007


On Fri, 27 Jul 2007 00:34:22 +0000, beginner wrote:

> 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?

The same way as you would do in Python: convert the argument into a tuple
if you *really* need a tuple, or just use it as sequence or via iterator. 
And pay attention to errors of course.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list