__name__

'' '
The __name__ properties:
Explanation: an executable module itself Python file, another program module is a first lead
in, the main program will run. If we want to be incorporated in the module, the module is a program
block is not performed, we can use __name__ only attribute to the program execution module itself running.
Each module has a __name__ attribute when the attribute value is equal to '__main__', on behalf of
the module itself executed, otherwise, is to be incorporated into other modules.

If the module is imported and run other modules, __ name__ value is the name of the module.
'' '
Import MU1

main DEF ():
Print ( "main ---------")
mu1.two ()
Pass # write to the file main content
DEF OTHER ():
Print ( "OTHER -------- ")

if __name__ == "__main__": # represents a direct operation of the file
# Print ( "123456789")
main ()
the else: # may be imported into other modules
# Print ( "asdfgh")
OTHER ()

 

Guess you like

Origin www.cnblogs.com/BKY88888888/p/11272153.html