On 7/19/2011 1:00 PM, Micah wrote:
That sounds artificially backwards; why not let getToken() reuse peekToken()?
def peek(self):
if self.tok is None:
try:
self.tok = self.gen.next()
If this is changed (as intended for the iteration protocol) to
self.tok = next(self.gen)
then this code (and OP's version) should run as is on both Py2.6/7 and Py3.
except StopIteration:
self.tok = NULL
return self.tok
def pop(self):
token = self.peek()
self.tok = None
return token
--
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list