code: def is_python(text, filename='<string>'):
      "Is this string a valid Python script?"
      try:
          compile(text, filename, 'exec')
      except (SyntaxError, TypeError):
          return False
      else:
          return Truf is_python(text, filename='<string>'):
      "Is this string a valid Python script?"
      try:
          compile(text, filename, 'exec')
      except (SyntaxError, TypeError):
          return False
      else:
          return True
docs: Is this string a valid Python script?