def slice_match(sub, counter):
if sub.start is not None and counter < sub.start:<EOL><INDENT>return False<EOL><DEDENT>if sub.stop is not None and counter >= sub.stop:<EOL><INDENT>raise StopIteration<EOL><DEDENT>if sub.step is not None:<EOL><INDENT>if sub.start is None:<EOL><INDENT>if counter % sub.step != <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if (counter - sub.start) % sub.step != <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT><DEDENT><DEDENT>return True<EOL>
Efficiently test if counter is in ``xrange(*sub)``

       Arguments:
        | ``sub``  --  a slice object
        | ``counter``  -- an integer

       The function returns True if the counter is in
       ``xrange(sub.start, sub.stop, sub.step)``.