Hi all,
I see a lot of books teaching beginning Python students to code like this:
def func1():
...
def func2():
...
class Blah(object):
...
def main():
...
main()
It strikes me that having people "def main():" and then call main() is a bit silly. In fact, it seems to be nothing more than a hold-over from C/C++.
My main gripe (heh, get it? "main"! I'm killin' 'em) with it is this: when my code breaks, I like to be able to inspect the values of variables. But if all of my code is enclosed in "main()", then the variables have all since gone out of scope and aren't available to be inspected.
So on a pragmatic level, I oppose the "def main():" style for the simple reason that it makes debugging a bit harder.
Are there any reasons that I should reconsider my dislike for "def main():"?
Thanks,
Jeff