How to select vertices, then convert to face selection with Python? I am brand new to Python, and cobbling things together from various sources, so I have next to NO idea what works, what doesn't work, or WHY things work.

I'm creating a script to apply a mirror modifier, then split the object into its two sides.  I'm using two slightly different routines depending on whether it is one symmetrical object with a center line, or two mirrored objects with no connected geometry.

When I used this code, it worked:

mesh = ob.data
bm=bmesh.from_edit_mesh(mesh)

bpy.ops.mesh.select_mode(type='VERT')
vtest = False  ##see if we can select side of active
for vert in bm.verts:
    if(vert.co[0] == 0):
      vert.select = True
      bm.select_history.add(vert)
      vtest = True
      break


if(vtest):  ## select side of active and part
    bpy.ops.mesh.select_axis(sign='NEG')
    bpy.ops.mesh.select_mode(type='FACE')
    bpy.ops.mesh.separate(type='SELECTED')


However, if I selected the vertices in a loop and tried to switch to face mode it dropped the selection.

  else:     
        for vert in bm.verts:
            if(vert.co[0] &lt;0):
                vert.select = True

        bpy.ops.mesh.select_mode(type='FACE')
        bpy.ops.mesh.separate(type='SELECTED')


This threw the error 'no selection.' and if I stopped the script just before the FACE selection mode switch, the mesh was in edit mode, all the vertices on the left side were selected, and if I then clicked face select mode, everything would be deselected.

I can't explain that.

The code that I finally got to work is BS and i'd like to know what fifty things I did wrong.

bm.select_mode = { 'FACE' }
bmesh.update_edit_mesh(ob.data)
bpy.ops.object.mode_set(mode = 'OBJECT', toggle = False)
bpy.ops.object.mode_set(mode = 'EDIT', toggle = False)
bpy.ops.mesh.select_mode(type='FACE')


If I leave out any of those lines, it fails.

My BASE question is: why can I select vertices using the 'select side of active' command, then swap into face mode and convert the selection to faces but if I select the vertices myself in a loop and switch, it drops them?
Flush the selection

The bmesh module has some methods for flushing selection.


  Selection / Flushing
  
  As mentioned above, it is possible to create an invalid selection
  state (by selecting a state and then de-selecting one of its
  vertices’s for example), mostly the best way to solve this is to flush
  the selection after performing a series of edits. this validates the
  selection state.


Test Script: run in edit mode, selects vertices with 

import bpy
import bmesh


context = bpy.context
ob = context.edit_object
me = ob.data

bm = bmesh.from_edit_mesh(me)
for v in bm.verts:
    v.select_set(v.co.z &lt; 0)

bm.select_mode = {'VERT', 'EDGE', 'FACE'}
bm.select_flush_mode()
#bm.select_flush(True) # or select flush, deselect all first. 
# put in tool in face select mode (without op)    
context.tool_settings.mesh_select_mode = (False, False, True)
#bpy.ops.mesh.separate(type='SELECTED')


After the flush above only faces with all vertices selected are selected.  Verts not part of a selected face are deselected.