Path: csiph.com!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'mrab': 0.05; 'elegant': 0.07; 'extracted': 0.07; 'attribute.': 0.09; 'elegant,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; ':-)': 0.12; "*isn't*": 0.16; 'magic': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:class': 0.16; 'thanks.': 0.18; 'not,': 0.22; 'header :User-Agent:1': 0.26; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; 'least': 0.27; 'catching': 0.29; 'solution,': 0.29; 'that.': 0.30; "i'll": 0.33; 'clear': 0.35; 'attempt': 0.35; 'something': 0.35; "isn't": 0.35; 'but': 0.36; 'there': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'thanks': 0.37; 'received:org': 0.37; 'thought': 0.37; 'to:addr:python.org': 0.40; 'where': 0.40; 'still': 0.40; 'further': 0.62; 'more': 0.63; 'latest': 0.64; '8bit%:21': 0.70; 'skip:\xe2 10': 0.70; 'obvious': 0.76; '_o__)': 0.84; 'expressive': 0.84; 'received:125': 0.84; 'mistake': 0.91; 'hong': 0.96; 'kong': 0.96 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Ensure unwanted names removed in class definition Date: Thu, 13 Aug 2015 08:55:50 +1000 References: <85fv3oj2y6.fsf@benfinney.id.au> <55CB62BE.4080403@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:o93cV73UjOhokgrGWg1pGqwcMOQ= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 1439420405 news.xs4all.nl 2921 [2001:888:2000:d::a6]:50791 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:95324 MRAB writes: > Have you thought about catching the NameError? I had not, but that is obvious now you say it. Thanks. Where there isn't a more elegant solution, I'll use that. It might not be elegant, but it's at least clear and expressive of the intent. Jussi Piitulainen writes: > Make them an implementation detail: > > plumage = [ > (__foo__, __bar__) for (__foo__, __bar__) in feathers.items() > if __bar__ == "beautiful" ] That still makes the name persist, so doesn't meet the requirements. It also commits the further mistake of using a ‘__dunder__’ name style for something that *isn't* a Python magic attribute. Thanks for the attempt :-) -- \ “Teeth extracted by the latest Methodists.” dentist | `\ advertisement, Hong Kong | _o__) | Ben Finney