def formatFieldEqVal(fieldNames, sepStr = " and "):
    """Format a (field1=value1) and (field2=value2)... clause
    in the form used with a data dictionary.
    This is intended to help generate select commands.

    Inputs:
    - fieldNames: a list or other sequence of field names
    - sepStr: the string to separate field=value pairs.

    Example:
    sqlCmd = "select * from %s where %s" % (tableName, formatFieldEqVal(fieldNames))
    dbCursor.execute(sqlCmd, dataDict)
    """
    fmtFieldList = ["(%s=%%(%s)s)" % (fieldName, fieldName) for fieldName in fieldNames]
    return sepStr.join(fmtFieldList)