How to use a vector of struct/class in python
Question: I can't seem to find a way to implement a vector in python

    
    
    struct Struct{
           int a, b;
    };
    

This is say a struct, and you could use it in a vector by declaring it

    
    
    Struct b[100];
    for (i = 0; i <= 99 ; i++)
        b[i]->a = i + 2;
        b[i]->b = i - 2;
    

So how do you this in python since the variables declare themselves?


Answer: `namedtuple` is good for making simple data containers:

    
    
    from collections import namedtuple
    Vector = namedtuple('Vector', 'a b')
    v = Vector(a=1, b=2)
    vv = [Vector(i-2, i+2) for i in range(100)]
    

