The preferred and most graceful way is to use neither, as others have pointed out. However, you can't return an exit code that way, and it sometimes isn't feasible to structure your code to allow it. I prefer SystemExit, because it doesn't require adding something to the namespace (the sys module), and it seems a bit more pythonic. You can trap it, however, which bugs me. I think these two should exhibit the same behavior. I'd use sys.exit for "real" code, even though it appeals less aesthetically, because it is less prone to doing something unexpected (one of Python's guiding principles, btw).
Cheers On Wednesday 11 August 2010, Bill Allen wrote: > I have only learned a couple of ways to cause a Python program to exit: > sys.exit(0) & raise.SystemExit . I am using this in a try/except block. > Which is preferred? Are there other, better ways? > > > Thanks, > Bill Allen _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor