How can i implement a C like struct,create an array of such a struct and read such data in Python?
typedef struct Pair{
int first_element,second_element;
}Pair;
Pair array_of_pairs[10];
Python arrays can contain anything - and they grow as needed so you don't need to put a hard-limit on the size.
Try this - it creates a namedtuple (good way to represent struct like things).
from collection import namedtuple
Pair = namedtuple("Pair", ["first", "second"])
p1 = Pair(1,2)
p2 = Pair(3,4)
list_of_pairs = [p1,p2]
print(list_of_pairs)
print(list_of_pairs[0]) just like in any python list,which i explicitly convert it into an array?IndexError if you try to access anything outside the bounds of the listcollections not collection. Try: from collections import namedtuple