def get_parse_error(code):
 code_buffer = StringIO(code)
 try:
  tabnanny.process_tokens(tokenize.generate_tokens(code_buffer.readline))
 except tokenize.TokenError as err:
  return ('Could not parse code: %s' % err)
 except IndentationError as err:
  return ('Indentation error: %s' % err)
 except tabnanny.NannyNag as err:
  return ("Ambiguous tab at line %d; line is '%s'." % (err.get_lineno(), err.get_line()))
 return None

def get_parse_error ( code ) : code_buffer = StringIO ( code ) try : tabnanny . process_tokens ( tokenize . generate_tokens ( code_buffer . readline ) ) except tokenize . TokenError as err : return ( 'Could not parse code: %s' % err ) except IndentationError as err : return ( 'Indentation error: %s' % err ) except tabnanny . NannyNag as err : return ( "Ambiguous tab at line %d; line is '%s'." % ( err . get_lineno ( ) , err . get_line ( ) ) ) return None
checks code for ambiguous tabs or other basic parsing issues .