Return and set

Micah larson.micah at gmail.com
Tue Jul 19 13:00:16 EDT 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