(script_text, filename)
return False
Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
Is this text as a whole a Python script? ( as opposed to shell / bat / etc .
def is_python_script(script_text, filename):
    """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
    """
    if filename.endswith('.py') or filename.endswith('.pyw'):
        return True  # extension says it's Python
    if is_python(script_text, filename):
        return True  # it's syntactically valid Python
    if script_text.startswith('#!'):
        # It begins with a '#!' line, so check if 'python' is in it somewhere
        return 'python' in script_text.splitlines()[0].lower()

    return False
def is_python_script ( script_text , filename ) : if filename . endswith ( '.py' ) or filename . endswith ( '.pyw' ) : return True # extension says it's Python if is_python ( script_text , filename ) : return True # it's syntactically valid Python if script_text . startswith ( '#!' ) : # It begins with a '#!' line, so check if 'python' is in it somewhere return 'python' in script_text . splitlines ( ) [ 0 ] . lower ( ) return False