Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'executed': 0.09; 'exit': 0.09; 'function,': 0.09; 'happen.': 0.09; 'subject:How': 0.10; 'called,': 0.16; 'unlikely': 0.16; 'wrote:': 0.18; 'module': 0.19; 'thu,': 0.19; 'error': 0.23; 'documented': 0.24; 'skip': 0.24; 'order.': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'change,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; '13,': 0.31; 'subject:some': 0.31; 'something': 0.35; 'received:google.com': 0.35; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'expect': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'ian': 0.60; 'reverse': 0.68; 'behavior': 0.77; 'condition.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=3E8GcIPgLzJSCL5Q60lAWZVSRKwqgBUIjkvRVXV3U+M=; b=FKp2ap0bIjK0ZXFNfb88sw+/3yrAHzSlLQz9yus9EyiFmRjIK/c3dscozVkzbMLyu6 qFLYeYRDBVC7e5tylv9b0cavowOubJrGa2XDyvp42nly13vhU6xMAxnyDoClJjT36NaP MvS9BIKTlANDD9SS3w/LYkNYL3nxTo5dy+NTKyLJLTib3PMFHGXaGqzfvJilEswX93/F P5mqT8CDFUcQje41n9+zYXrTo+K3imSGgJgF2kIwo2lgy28EWwLfp0JcZxNHU22P2PVE TnGT9rfMf8H7sRImtfnkMo9j1qmkr3EduGnxEf/sv0zZjGjaDu6CBPEEea/gXKv9cXRe 9QSQ== X-Received: by 10.70.102.234 with SMTP id fr10mr5747666pdb.145.1415918972907; Thu, 13 Nov 2014 14:49:32 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <71b9a111-283f-4006-bc9d-e35782d9888c@googlegroups.com> <5464F958.4070404@stoneleaf.us> From: Ian Kelly Date: Thu, 13 Nov 2014 15:48:52 -0700 Subject: Re: How about some syntactic sugar for " __name__ == '__main__' "? To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415918976 news.xs4all.nl 2889 [2001:888:2000:d::a6]:42166 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80709 On Thu, Nov 13, 2014 at 1:44 PM, Skip Montanaro wrote: > On Thu, Nov 13, 2014 at 2:33 PM, Ian Kelly wrote: >> ... other things decorated with atexit.register >> might actually be called before the main function > > I don't think that will happen. The atexit module is documented to > execute its exit functions in reverse order. Right, so if something else gets registered after the main function, it will be called before the main function. > What's not documented is > the behavior of calling atexit.register() while atexit._run_exitfuncs > is running. That's an implementation detail, and though unlikely to > change, it might be worthwhile getting that behavior documented. Since the exit functions are executed in reverse order, anything registered at this time would have to be called before something else that has already been called, so I would expect this to be an error condition.