Re:Don't Pipe to your Shell
by mercurial on Friday November 01, 2013 @03:57AM
(#6652416)
I realize that I tend to do that by default in my shell scripts. After a few years of Python, I always make a main() function which gets the command line parameters. Is this weird?
[ Parent
| on HN ]
If you're weird, I'm weird too.
It just seems to me that the main should worry about interfacing with the outside world, and the rest of your code should really just be written as a library.
Yes, my main usually does little more than argument handling.
Not really weird - it allows for more composability if you ever need to go that way.
I think I do that to avoid global variables as much as possible, as well. Declaring things as "local" tends to keep me honest, as opposed to having a bunch of junk cluttering the global namespace.