The import statement combines two operations; it searches for the named module, then it binds the results of that search to a name in the local scope. The search operation of the import statement is defined as a call to the import() function, with the appropriate arguments. The return value of import() is used to perform the name binding operation of the import statement. See the import statement for the exact details of that name binding operation.
import file using python
To print 'file2' your code, you need to pass it as a command to the Python interpreter,
python myscript.py
there's no main()
function that gets run automatically, so the main()
function is implicitly all the code at the top level, and call if __name__ == "__main__"
How main does in python