Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'main()': 0.05; '__name__': 0.09; 'am,': 0.12; 'library': 0.13; 'case.': 0.15; "'__main__':": 0.16; 'hides': 0.16; 'subject:case': 0.16; 'cc:addr:python-list': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'functions,': 0.18; 'header :In-Reply-To:1': 0.22; 'feb': 0.22; 'code,': 0.28; 'asking': 0.28; 'pass': 0.29; 'subject:skip:a 10': 0.29; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'solved': 0.30; 'threads': 0.30; 'message- id:@gmail.com': 0.31; 'do.': 0.31; 'thanks': 0.32; 'that,': 0.32; 'supposed': 0.32; 'usual': 0.32; 'there': 0.33; 'header:User- Agent:1': 0.33; 'done': 0.34; 'sense,': 0.34; 'try:': 0.34; 'things': 0.35; 'received:209.85.214': 0.36; 'cc:2**1': 0.36; 'received:10.0.0': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'authors': 0.38; 'should': 0.38; 'that.': 0.39; 'except': 0.39; 'received:209': 0.39; "you've": 0.61; 'your': 0.61; 'perfect': 0.64; '01:52': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=YgkDnx51FV6RlNY8S9mBh42qs9yAQC3VtXqypq5BF58=; b=aEudQMg2WDD1PKAqDJ1hUGP3pSNdSYdykn8iPOJjpGiTYVwg5MsV7Y9Mne2nHlzbNV WpDRDntVnG76BaFXhi8+mfvIJtRzsH5sixvugbUAmuXVV2MCg/cXl/R+g77VI0HRjMIY vTloLL4l3SMBcvrHzVuNq6LaazNWXQ8lltVEI= Date: Wed, 15 Feb 2012 14:35:33 +0000 From: Andrea Crotti User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111224 Thunderbird/9.0.1 MIME-Version: 1.0 To: Devin Jeanpierre Subject: Re: atexit.register in case of errors References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: python-list@python.org, mwilson@the-wire.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329316538 news.xs4all.nl 6903 [2001:888:2000:d::a6]:42559 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20442 On 02/15/2012 01:52 PM, Devin Jeanpierre wrote: > On Wed, Feb 15, 2012 at 8:33 AM, Mel Wilson wrote: >> The usual way to do what you're asking is >> >> if __name__ == '__main__': >> main() >> goodbye() >> >> and write main so that it returns after it's done all the things it's >> supposed to do. If you've sprinkled `sys.exit()` all over your code, then >> don't do that. If you're forced to deal with a library that hides >> `sys.exit()` calls in the functions, then you have my sympathy. Library >> authors should not do that, and there have been threads on c.l.p explaining >> why they shouldn't. > In such a case. one can do:: > > if __name__ == '__main__': > try: > main() > except SystemExit: > pass > goodbye() > > -- Devin Makes perfect sense, I solved like this then, thanks