On 14Oct2009 19:58, Peng Yu <pengyu...@gmail.com> wrote:
| On Wed, Oct 14, 2009 at 7:57 PM, Joe Riopel <goo...@gmail.com> wrote:
| > On Wed, Oct 14, 2009 at 8:53 PM, Peng Yu <pengyu...@gmail.com> wrote:
| >> I have the following python code snippet. I'm wondering what command I
| >> should use to terminate the program if the arguments are not right.
| >
| > I usually use sys.exit.
| 
| I actually wanted to ask what return code should be returned in this
| case when the arguments are not right. Thank you1

It should be non-zero (0 means "success"). Generally, having lots of possible
values for failure (anything non-zero) lets programs indicate the reason for
the failure. For example, rsync and sendmail have specific exit codes for
specific problems. Most programs don't have or need that degree of detail.
Unless there are special circumstances my own convention is to use 2 for a
usage/wrong-arguments failure and 1 for "this didn't work".

Cheers,
-- 
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Don't have awk? Use this simple sh emulation:
    #!/bin/sh
    echo 'Awk bailing out!' >&2
    exit 2
- Tom Horsley <tahors...@csd.harris.com>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to