Return and set
Billy Mays
81282ed9a88799d21e77957df2d84bd6514d9af6 at myhashismyemail.com
Tue Jul 19 13:12:32 EDT 2011
On 07/19/2011 01: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()
> except StopIteration:
> self.tok = NULL
> return self.tok
>
> def pop(self):
> token = self.peek()
> self.tok = None
> return token
I actually like this way better, thanks!
--
Bill
More information about the Python-list
mailing list