Can't use len() on returned PyList object?
gmcm at hypernet.com
Mon Nov 8 22:15:01 EST 1999
> Why can't I use 'len()' to find the length of a list
> returned from my new extension module? The error is
> shown as:
> TypeError: call of non-function (type int)
> The list was created by 'PyList_New()' and populated
> using 'PyList_SetItem()'. I get the same error message
> regardless of the data type held in the list. I can
> access each element of the list just fine, but I don't
> always know how many there are. Is there a reasonable
> way for me to find the length of these lists in Python
> other than returning the length from the extension as a
> separate object?
Most likely you've clobbered the name "len" by binding it to an
integer (as the error msg so tersely implies). Probably nothing
wrong with your extension.
More information about the Python-list