Return and set

Micah larson.micah at
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:
            self.tok =
        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