Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect argument passing convention of a C library function

Tags:

python

cpython

With pure Python functions you can pass arguments either by order (e.g. foo(1, 2, 3)) or by name (e.g. foo(a=1, c=3, b=2)).

Functions defined in C modules can use either convention. You cannot say range(stop=10, step=2), and so it is with most but not all functions implemented using C interface.

Is there a way to determine the argument passing convention of a function from within Python?

like image 960
9000 Avatar asked Jul 01 '11 17:07

9000


1 Answers

It appears to be an open bug: there is simply no way to tell this. Also, the issue is implementation-dependent: your code might work in (for example) PyPy, though I can't confirm this.

The devs on the bug page aren't sure whether to change the documentation style or the implementation, but I get the impression it's not a pressing issue for them either way.

like image 137
RoundTower Avatar answered Oct 12 '22 08:10

RoundTower