def main():
pass # do stuff here
if __name__ == "__main__":
main()
When a Python module is imported,
__name__
is set to the module’s filename (without the.py
extension). This check ensures thatmain()
runs only when the script is executed directly, not when it's imported as a module.