|Ned Batchelder : Blog | Code | Text | Site|
Python main() functions
» Home : Blog : June 2003
A few weeks ago, Guido van Rossum wrote about Python main() functions in his weblog. There are good ideas in there, but I didn't agree with them all. In particular, I thought this was odd:
To me, it is better to keep the sys.exit and the sys.argv in one place:
The weblog has an active comment system, with Guido responding thoughtfully. After I posted my thoughts, he agreed to "compromise" with me!
By the way: one trick I've used in main() functions: when converting numeric arguments from strings in argv, use eval(), not int(). That way, you can use any numeric calculations you want in your command line arguments.