__name__ and HTTP servers
The __name__ built-in Python variable which describes exactly that - it's the name of the module during runtime. Python modules use this variable to perform a particular action when the module is run, and probably do something else when imported by another module. It also facilitates module testing if you think about it.
Ideally, every Python module that is intended to be reused must have something like this in it, preferably at the end.
if __name__ == "__main__":
print "Just got executed!"
else:
print "Got imported! I'm so cool!"
Continue reading →