def test_slices(self): self.assertEqual(list(slices(self.seq, ':3')), [['a0', 'a1', 'a2'], ['b0', 'b1', 'b2']]) self.assertEqual( list(slices(self.seq, ':.3, 5', dialect='dot_notation')), [['a0', 'a1', 'a4'], ['b0', 'b1', 'b4']])
def test_slices(self): self.assertEqual(list(slices(self.seq, ':3')), [['a0', 'a1', 'a2'], ['b0', 'b1', 'b2']]) self.assertEqual(list(slices(self.seq, ':.3, 5', dialect='dot_notation')), [['a0', 'a1', 'a4'], ['b0', 'b1', 'b4']])
rows = [ ['alpha-1', 'alpha-2', 'alpha-3', 'alpha-4', 'alpha-5', 'alpha-6'], ['beta-1', 'beta-2', 'beta-3', 'beta-4', 'beta-5', 'beta-6'], ['gamma-1', 'gamma-2', 'gamma-3', 'gamma-4', 'gamma-5', 'gamma-6'], ] dialect = True while dialect: print(Grammar().list_dialects()) dialect = input('\nEnter dialect? ') if dialect and dialect in Grammar().get_dialects(): columns = True while columns: print() columns = input('\nSelect columns? ') if columns: try: # main workhorse function rows = slices(rows, columns, dialect) for row in rows: print(row) except InvalidSliceString as error: print('InvalidSliceString: {}'.format(error)) except EndPointZeroNotAllowedError as error: print('EndPointValueError: {}'.format(error))