Python prim filter