<s> import itertools <EOL> def aritprog_gen ( begin , step , end = None ) : <EOL> if end is not None and begin >= end : <EOL> return <EOL> yield type ( begin + step ) ( begin ) <EOL> tail_gen = itertools . count ( begin + step , step ) <EOL> if end is not None : <EOL> tail_gen = itertools . takewhile ( lambda n : n < end , tail_gen ) <EOL> for x in tail_gen : <EOL> yield x </s>
