How to add a UV Map to a Mesh Using Python I've made a script that creates a mesh in Blender using a binary file containing mesh data. That works fine, but now I need to get textures on the mesh and I want to create a UV map from the UV data in the file. However, I can't figure out how to add the UVs to the mesh.

Ideally, I'd like some system that lets me add a UV per vertex as I add the vertices. Should I be using UV loops? I don't really know what they are, but there is some information about BMLoopUV at the following url, although no example usage:
http://www.blender.org/documentation/blender_python_api_2_67_release/bmesh.types.html#bmesh.types.BMLoopUV
There are 2 existing resources that show this:

The best is the template for this purpose that comes with blender 2.67:

See Text Editor -> Templates -> Python -> Operator UV.

There is also a snippet in BMesh docs.