Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.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.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '"if': 0.09; '__name__': 0.09; 'executed': 0.09; 'executes': 0.09; 'implemented.': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'decade,': 0.16; 'exactly,': 0.16; 'hides': 0.16; 'how,': 0.16; 'merely': 0.16; 'namespace,': 0.16; 'pythonic': 0.16; 'such,': 0.16; 'wrote:': 0.18; 'discussion': 0.18; 'wed,': 0.18; 'module': 0.19; "python's": 0.19; 'programming': 0.22; 'cc:addr:python.org': 0.22; 'string,': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'idea,': 0.31; 'proposing': 0.31; 'subject:some': 0.31; 'worked': 0.33; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'too': 0.37; 'two': 0.37; 'being': 0.38; 'nov': 0.38; 'pm,': 0.38; '12,': 0.39; 'url:mail': 0.40; 'how': 0.40; 'details.': 0.61; 'john': 0.61; 'name': 0.63; 'myself': 0.63; 'determine': 0.67; 'bothered': 0.68; 'deeply': 0.69; 'idiom': 0.84; 'joel': 0.91; 'to:none': 0.92; 'students,': 0.95; 'taught': 0.96; 'invite': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=LUX6ZjgzkH9m8KSZ95bXpSv45tPjP5zuwPbZGUFDDWM=; b=IlYm+w+FKy9zRq7raS9V5lH8lLycFHlce01Ffw+9zGxDTUCrqpiWCtluJ6nk1oxPk6 sHlDkUao5YPXAASctVHWRnyOpEfVIur+XQWJMJ3IYUHIj1IZGCXpoDrnKqTsrBhAFNDM KBmraj6xrLU9hR6wAXZwrySVAMFZ7xtXCx0whGOTuVfJszbMuI2z1u17p/gEXZ92ejfI /y6H9Uv6TwKv5OzmH1/Jl+D5rnmAfs0Rz7uPuFCa/+olO9eowa+0pu/NZdzKHwkEQrpH +LUFHwM2Yj/OKSE7KkL30410Fnd4jUfZiXjT6fSLQqiEDZUp2RL4w0g80WS9hGrV+wvL R+iA== MIME-Version: 1.0 X-Received: by 10.140.92.2 with SMTP id a2mr60690613qge.51.1415826475188; Wed, 12 Nov 2014 13:07:55 -0800 (PST) In-Reply-To: <71b9a111-283f-4006-bc9d-e35782d9888c@googlegroups.com> References: <71b9a111-283f-4006-bc9d-e35782d9888c@googlegroups.com> Date: Wed, 12 Nov 2014 16:07:55 -0500 Subject: Re: How about some syntactic sugar for " __name__ == '__main__' "? From: Joel Goldstick Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415826477 news.xs4all.nl 2906 [2001:888:2000:d::a6]:33615 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80627 On Wed, Nov 12, 2014 at 4:02 PM, John Ladasky wrote: > I have taught Python to several students over the past few years. As I h= ave worked with my students, I find myself bothered by the programming idio= m that we use to determine whether a module is being executed or merely imp= orted: > > "if __name__ =3D=3D '__main__':" > > The use of two dunder tokens -- one as a name in a namespace, and the oth= er as a string, is intimidating. It exposes too much of Python's guts. As= such, I think that it is less Pythonic than we might want. Myself, I've b= een programming in Python for a decade, and I still haven't dug very deeply= into what exactly __name__ means or does. > > I would like to start a discussion about whether Python should include a = function which executes this evaluation, and hides all of the unfriendly du= nderish details. And if that's a good idea, I would invite a discussion of= how, exactly, it should be implemented. I'm nowhere near proposing a PEP,= but that may come later. > > Thanks for your thoughts. > -- > https://mail.python.org/mailman/listinfo/python-list How about a decorator? --=20 Joel Goldstick http://joelgoldstick.com