Python n00b Tip

As I was surfing wikipedia learning about design patterns, I saw this interesting piece of code in the python example of the command design pattern:

# Execute if this file is run as a script and not imported as a module 
if __name__ == "__main__": 
    light_switch = LightSwitch() 
    print("Switch ON test.") 

I am referring to the if __name__ == "__main__" thing. This is probably the most n00bish Python tip of all time, but it has always slipped my mind! I am sure I heard its purpose before… In any case, there you have it. I am sure it won’t slip my mind again this time! … I hope.

On a side note, progress on the part 4 of the map editor thing is still WIP, and coming along nicely. It will probably take a while, since it’s a long one. Reading about design patterns is also urging me to write something about that, too. But, I don’t know. It is covered super clearly in wikipedia.