I think this appeared as an old Launchpad question (#224015) referring both to BCs and to subdomains from GMSH, but to avoid posting a link and so it ends up under Q&A too, I'll quote Michael Waste from there (with thanks):
In the "geo file" you have to rename manually the subdomains with 0 and 1. Also the volumes need integer numbers beginning from 0.
then you can reference to the corresponding boundaries and subdomains in the python file.
mesh = Mesh("yourmeshfile.xml")
subdomains = MeshFunction("size_t", mesh, "yourmeshfile_physical_region.xml")
boundaries = MeshFunction("size_t", mesh, "yourmeshfile_facet_region.xml")
bcs = [DirichletBC(V, 5.0, boundaries, 1),# of course with your boundary
DirichletBC(V, 0.0, boundaries, 0)]
That approach has worked for me.