Hacker News new | past | comments | ask | show | jobs | submit login

Even simpler would be:

  function install_my_software() {
    ...
  }

  install_my_software()
If the script is partially downloaded, it won't have any effect.



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?


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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: