Return list of associated vertex index, weight values for a given vertex_group I am currently porting some code from the 2.49 API to the 2.6 API and looking for a nice way to replace this function call

vert_list["bone"] = b_obj.data.getVertsFromGroup("bone", 1)


This function returned a list of vertex tuples (index, weight).

Edit: A nice side effect of this function was that it also threw an AttributeError if the had no associated vertices group. Empty VertGroups are not allowed by our exporter. 

I coded up a working sample for what I think I need based on the 2.49 API to show how I intend to access these values. This has been simplified with hard coded values.

import bpy

b_obj = bpy.data.objects['Cube']
b_verts = b_obj.data.vertices
b_arm = bpy.data.objects['Armature']


b_vert_group = b_obj.vertex_groups['Bone']
b_group_index = b_vert_group.index
b_list = []

for b_vert in b_verts:
    for g in b_vert.groups:
        if g.group == b_group_index:
            b_list.append((b_vert.index, g.weight))


What I am wondering is if anyone has an alternative way of accessing these values or perhaps someone would give a more pythonic version.

Most of the samples I have encountered relating to vertex groups are geared towards assignment rather than access. Even if I don't get an answer it might help someone else down the road.
No, there are no built-in functions which do this in a more pythonic way, however, unless you only ever want to access a single bone, Id suggest collecting all vertex groups at once.

def mesh_to_weight_list(ob, me):
    """
    Takes a mesh and return its group names and a list of lists,
    one list per vertex.
    aligning the each vert list with the group names,
    each list contains float value for the weight.
    """

    # clear the vert group.
    group_names = [g.name for g in ob.vertex_groups]
    group_names_tot = len(group_names)

    if not group_names_tot:
        # no verts? return a vert aligned empty list
        return [[] for i in range(len(me.vertices))], []
    else:
        weight_ls = [[0.0] * group_names_tot for i in range(len(me.vertices))]

    for i, v in enumerate(me.vertices):
        for g in v.groups:
            # possible weights are out of range
            index = g.group
            if index &lt; group_names_tot:
                weight_ls[i][index] = g.weight

    return group_names, weight_ls


Note, that this example could use pythons array module for greater effeciency but using lists since its an example.