Re: [Tutor] a graceful program exit

2010-08-12 Thread Bill Allen
On Thu, Aug 12, 2010 at 6:35 AM, Steven D'Aprano wrote: > On Thu, 12 Aug 2010 04:59:26 pm Chris Fuller wrote: > > 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 > > Of course you can. Exiting out the end of th

Re: [Tutor] a graceful program exit

2010-08-12 Thread Steven D'Aprano
On Thu, 12 Aug 2010 04:59:26 pm Chris Fuller wrote: > 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 Of course you can. Exiting out the end of the program returns an exit code of zero, and raising an uncaught e

Re: [Tutor] a graceful program exit

2010-08-12 Thread Chris Fuller
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 mo

Re: [Tutor] a graceful program exit

2010-08-11 Thread Hugo Arts
On Wed, Aug 11, 2010 at 11:06 PM, James Mills wrote: > On Thu, Aug 12, 2010 at 1:42 PM, 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 othe

Re: [Tutor] a graceful program exit

2010-08-11 Thread James Mills
On Thu, Aug 12, 2010 at 1:42 PM, 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? The normal pattern is to have an entry poi

[Tutor] a graceful program exit

2010-08-11 Thread Bill Allen
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.