def evaluate_slice_index(arg):
 if hasattr(arg, '__index__'):
  return operator.index(arg)
 else:
  raise TypeError('slice indices must be integers or None or have an __index__ method')

def evaluate_slice_index ( arg ) : if hasattr ( arg , '__index__' ) : return operator . index ( arg ) else : raise TypeError ( 'slice indices must be integers or None or have an __index__ method' )
helper function to convert a slice argument to an integer .