def selected_index(view):
 indices = view.selectedIndexes()
 assert (len(indices) < 2), 'View must be in single selection mode'
 if indices:
  return indices[0].row()
 else:
  return (-1)

def selected_index ( view ) : indices = view . selectedIndexes ( ) assert ( len ( indices ) < 2 ) , 'View must be in single selection mode' if indices : return indices [ 0 ] . row ( ) else : return ( - 1 )
return the selected integer index in the view .