Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80710

Re: How about some syntactic sugar for " __name__ == '__main__' "?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python3': 0.07; 'subject:How': 0.10; 'python': 0.11; 'def': 0.12; '2.7': 0.14; 'main():': 0.16; 'unlikely': 0.16; 'wrote:': 0.18; 'differ': 0.19; 'thu,': 0.19; 'seems': 0.21; 'import': 0.22; 'documented': 0.24; 'skip': 0.24; 'header:In-Reply-To:1': 0.27; 'url:bugs': 0.29; 'change,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; '13,': 0.31; 'subject:some': 0.31; 'url:python': 0.33; 'received:google.com': 0.35; 'url:org': 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'between': 0.67; 'behavior': 0.77
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=viX7ceHZ5jAb/V+xKv9DGMSFTTV7dpb1TD6quM+YTtA=; b=ll5twgg2W0tsnReAZ+cD0SaISlm6aixEOFnJUk27NaU2Goz5vsMDks9KQCc1THJt9e DTUJdUBjhjjvJv3PwuTjZXJRfqxkLSm0ghQ71p0va3X3/hJElwFrY4sbPZ3BRyZ2DdzA HYXQ3zkItIuKHIfJEUqDNu/JWvk43cCZP4oeR1eL7HE0ZGWl7fpsnIUgQT/tnhuC5xwT 2GkoRSRHSgpdEPdeuL23QZBoT1DSmPuxPTQnJBrwMvqa+hsCR3p5lCJYHwIAzifR3Zi3 OoVKZbOzZAThGOgZjDMVEWapi5iuTnjismiOct8/KguemCKXWFjcxiIfOv0GqfCB6Vak AygA==
X-Received by 10.70.45.233 with SMTP id q9mr6176614pdm.24.1415919433865; Thu, 13 Nov 2014 14:57:13 -0800 (PST)
MIME-Version 1.0
In-Reply-To <CANc-5UxytJ42uY2RW5cLjkQUowYt_qaq056h96inr2xkOYyqtQ@mail.gmail.com>
References <71b9a111-283f-4006-bc9d-e35782d9888c@googlegroups.com> <CAPM-O+yukMKq8m1Udcw23=kgPc6zvncfS1ohPcyme_4RXMTATg@mail.gmail.com> <CALvWhxuo8EB_FqkeUXe9nRj1CGFxrVtzw76afc21cB5=D4aZwg@mail.gmail.com> <CALwzid=i6vKUnQU1pfO3qs8H5u+_J4ff_XdkQUxt4ajN5JNYfQ@mail.gmail.com> <5464F958.4070404@stoneleaf.us> <CALwzid=uiDQrn7PSUrD=U-u-4shXexwCGb9bgCueYdtC0uEjeg@mail.gmail.com> <CANc-5UwMLfou7HCBJ1hQKYt8duxHOvsaNZMvxvSMev8dPHaccg@mail.gmail.com> <CANc-5UxytJ42uY2RW5cLjkQUowYt_qaq056h96inr2xkOYyqtQ@mail.gmail.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Thu, 13 Nov 2014 15:56:33 -0700
Subject Re: How about some syntactic sugar for " __name__ == '__main__' "?
To Python <python-list@python.org>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15792.1415919443.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415919443 news.xs4all.nl 2964 [2001:888:2000:d::a6]:44995
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80710

Show key headers only | View raw


On Thu, Nov 13, 2014 at 1:53 PM, Skip Montanaro
<skip.montanaro@gmail.com> wrote:
> On Thu, Nov 13, 2014 at 2:44 PM, Skip Montanaro
> <skip.montanaro@gmail.com> wrote:
>> 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.
>
> http://bugs.python.org/issue22867

In fact it seems the behavior does differ between Python 2.7 and Python 3.4:

$ cat testatexit.py
import atexit

@atexit.register
def main():
  atexit.register(goodbye)

@atexit.register
def goodbye():
  print("Goodbye")
$ python2 testatexit.py
Goodbye
Goodbye
$ python3 testatexit.py
Goodbye

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How about some syntactic sugar for " __name__ == '__main__' "? John Ladasky <john_ladasky@sbcglobal.net> - 2014-11-12 13:02 -0800
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-12 16:07 -0500
  Re: How about some syntactic sugar for " __name__ == '__main__' "? John Ladasky <john_ladasky@sbcglobal.net> - 2014-11-12 13:17 -0800
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ethan Furman <ethan@stoneleaf.us> - 2014-11-12 13:19 -0800
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Chris Kaynor <ckaynor@zindagigames.com> - 2014-11-12 13:33 -0800
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Marko Rauhamaa <marko@pacujo.net> - 2014-11-12 23:52 +0200
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-12 14:51 -0700
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-12 15:55 -0600
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Chris Kaynor <ckaynor@zindagigames.com> - 2014-11-12 14:09 -0800
    Re: How about some syntactic sugar for " __name__ == '__main__' "? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-15 22:09 +1100
      Re: How about some syntactic sugar for " __name__ == '__main__' "? Marko Rauhamaa <marko@pacujo.net> - 2014-11-15 13:54 +0200
      Re: How about some syntactic sugar for " __name__ == '__main__' "? Vito De Tullio <vito.detullio@gmail.com> - 2014-11-16 11:26 +0100
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-12 15:19 -0700
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Terry Reedy <tjreedy@udel.edu> - 2014-11-12 18:19 -0500
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Chris Angelico <rosuav@gmail.com> - 2014-11-13 10:26 +1100
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Terry Reedy <tjreedy@udel.edu> - 2014-11-12 19:35 -0500
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Chris Angelico <rosuav@gmail.com> - 2014-11-13 11:54 +1100
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ethan Furman <ethan@stoneleaf.us> - 2014-11-13 10:32 -0800
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-13 13:33 -0700
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ethan Furman <ethan@stoneleaf.us> - 2014-11-13 12:43 -0800
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-13 14:44 -0600
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-13 14:53 -0600
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-13 15:48 -0700
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-13 15:56 -0700
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-15 21:52 +1100
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Vito De Tullio <vito.detullio@gmail.com> - 2014-11-16 11:39 +0100
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-16 10:15 -0700
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ethan Furman <ethan@stoneleaf.us> - 2014-12-01 15:19 -0800
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ethan Furman <ethan@stoneleaf.us> - 2014-12-01 16:45 -0800
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Chris Angelico <rosuav@gmail.com> - 2014-12-02 12:15 +1100
  Re: How about some syntactic sugar for " __name__ == '__main__' "? Ethan Furman <ethan@stoneleaf.us> - 2014-12-02 02:17 -0800

csiph-web