Python: Selecting faces from a Material Index
import bpy
    import bmesh

    index = 2  # required index

    bpy.ops.object.mode_set(mode = 'EDIT')         
    ob = bpy.context.object                  
    me  = ob.data
    bm = bmesh.from_edit_mesh(me)        

    for face in bm.faces:      
        if face.material_index == index:
            face.select = True


    me.update()