def _parse_number(stream):
 rv = ''
 while (stream.peek() and (stream.peek() in string.digits)):
  rv += next(stream)
 return int(rv)

def _parse_number ( stream ) : rv = '' while ( stream . peek ( ) and ( stream . peek ( ) in string . digits ) ) : rv += next ( stream ) return int ( rv )
expects the stream to contain a number next .