What do you call the part at the end of a Python program that begins like this?

if __name__ == '__main__':

It's not really a function or a method. Is it the "main script"?

Follow

@peterdrake Its an if statement which exists in the root of the code (not inside any class or function)... it would also work without the if statement except for the fact that you'd no longer be able to import the file

@freemo Yeah, I get how it works. I'm just trying to figure out what it's called.

@peterdrake The "main code block" would be the most appropriate term. If there is only one you can more generally call it "The program entry point"

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.