Usually when you "automatically" run fun()
by importing a script, any code within the main block (if __name__ == "__main__":
) will be executed when the script is imported.
Now when you run fun()
"by hand", you are basically calling the function from the interpreter to another script.