Deleting vertex groups

How on earth does one delete a vertex group from an object in python? Or rather, how do you tell blender what vertex group to delete when using bpy.ops.object.vertex_group_remove? I have to admit, this whole concept of context+operator has me completely befuddled.

First get context…
Make the vg named “Group” active (the object that has this vg has context)


>>> bpy.ops.object.vertex_group_set_active(group='Group')
{'FINISHED'}

then you can run operators on it


>>> bpy.ops.object.vertex_group_remove()
{'FINISHED'}

Alternatively, using API methods rather than operators


import bpy

obj = bpy.context.object

vg = obj.vertex_groups.get('Group.001')

if vg is not None:
    obj.vertex_groups.remove(vg)

That’s exactly what I was looking for. Thank you!