<s> class Lookahead ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , gen ) : <EOL> """<STR_LIT>""" <EOL> self . _g = iter ( gen ) <EOL> self . _atend = False <EOL> self . _advance ( ) <EOL> self . _atstart = True <EOL> def _advance ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> self . _atstart = False <EOL> self . _x = self . _g . next ( ) <EOL> except StopIteration : <EOL> self . _x = None <EOL> self . _atend = True <EOL> @ property <EOL> def atend ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _atend <EOL> _atstart = True <EOL> @ property <EOL> def atstart ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _atstart <EOL> @ property <EOL> def peek ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _x <EOL> def __iter__ ( self ) : <EOL> """<STR_LIT>""" <EOL> return self <EOL> def next ( self ) : <EOL> if self . _atend : <EOL> raise StopIteration <EOL> _x = self . _x <EOL> self . _advance ( ) <EOL> return _x <EOL> def __next__ ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . next ( ) </s>
