Dec 182010
How do I find the current module name in Python?
Answer:
The easiest way is to look at the look at the predefined global variable __main__. If it has the value "__main__", it means the program is run as a script (not as imported module).
E.g.
def main():
print 'Running test...'
if __name__ == '__main__':
main()