Why call main() with this conditional?

So here is a snippet of code:

def main():

counter = 0
#collect data
GUIDs = rs.GetObjects(‘select objects’)
#call my system class
obj01 = MySystemClass(GUIDs, counter)

if (name == “main”):

Does anyone know why I would use the second from last line conditional to call the main() function? Does this have something to do with me setting up my own code as a module and potentially having to call it to run from outside itself?




Indeed it prevents a call of main() when the script is loaded as a module in another script:


Sorry weird formatting of the link but the double dashes were being parsed as bold setters

1 Like

Super! Thanks for your help Willem!


1 Like