[Tutor] subscript problem

Alan Gauld alan.gauld@blueyonder.co.uk
Tue Jun 3 17:11:11 2003


> I am having a problem with handling some pointers. 
> My problem is like this:
> 
> typedef struct ab
> {
>       short n_p;

Thus far we see C code

> Now the function:
> 
> XYZ(AB* out)

Which also looks like old style C with its 
implicit integer return type...

>         v_start = out -> po[first];   // v_start is of type Vec.
> }
> 
> 
> The problem is that when i use po[first] it gives 
> an error message saying that 
> AttributeError: Vec instance has no attribute '__getitem__'
> 

Which looks like a Python error. Can you show us where 
python is getting called? You have pure C code hee so 
far as I can tell.

po is a pointer to Vec which in C could be an array of 
Vec - you certainly seem to assume so othewise 
indexing makes no sense!is a struct so where is the 
function called from? With what arguments? And where 
does Python come into this?

A Puzzled Python Tutor,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld