[Tutor] a graceful program exit

Hugo Arts hugo.yoshi at gmail.com
Thu Aug 12 08:46:46 CEST 2010


On Wed, Aug 11, 2010 at 11:06 PM, James Mills
<prologic at shortcircuit.net.au> wrote:
> On Thu, Aug 12, 2010 at 1:42 PM, Bill Allen <wallenpb at gmail.com> 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 point and an exit point.
>
> main() and SystemExit exception.
>
> cheers
> James
>

I usually just have the top of the program as entry point, and the
bottom as exit. I like the simplicity.


More information about the Tutor mailing list