Next / Previous / Contents / TCC Help System / NM Tech homepage

21. Code epilogue

The last lines of the script will actually run the application—provided it has been run as a script, in which case Python will set the built-in __name__ variable to "__main__". If another script wishes to import this script in order to reuse some of its pieces, name will not be set to "__main__" while the script is being read, and in that case main() will not be called.

huey
#================================================================
# Epilogue
#----------------------------------------------------------------

# [ if this file is being run as a script ->
#     run an instance of the Application class
#   else -> I ]
if  __name__ == '__main__':
    main()