Return and set

Micah larson.micah at gmail.com
Tue Jul 19 19:00:16 CEST 2011


That sounds artificially backwards; why not let getToken() reuse peekToken()?

def peek(self):
    if self.tok is None:
        try:
            self.tok = self.gen.next()
        except StopIteration:
            self.tok = NULL
    return self.tok

def pop(self):
    token = self.peek()
    self.tok = None
    return token



More information about the Python-list mailing list