Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python __name__ == "__main__"

if __name__ == "__main__"

// Every Python module has it’s __name__ defined 
// and if this is ‘__main__’, 
// it implies that the module is being run 
// standalone by the user and we can do corresponding
// appropriate actions.

// If you import this script as a module 
// in another script,
// the __name__ is set to the name
// of the script/module.
// Python files can act as either reusable modules, 
// or as standalone programs.

// if __name__ == “main”: is used to execute some 
// code only if the file was run directly, 
// and not imported.
Source by www.codecademy.com #
 
PREVIOUS NEXT
Tagged: #Python
ADD COMMENT
Topic
Name
8+4 =