Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:module': 0.04; 'defines': 0.07; 'names.': 0.07; 'python': 0.08; 'dict': 0.09; 'received:64.4': 0.09; 'attribute,': 0.16; 'subject:global': 0.16; 'underscore.': 0.16; 'otherwise,': 0.19; 'detect': 0.22; 'header :In-Reply-To:1': 0.22; 'module,': 0.23; "didn't": 0.29; 'module': 0.30; 'kelly': 0.30; 'thanks': 0.31; 'does': 0.32; 'to:addr :python-list': 0.34; 'header:User-Agent:1': 0.34; 'it?': 0.34; 'then.': 0.35; 'charset:us-ascii': 0.36; 'sequence': 0.37; 'another': 0.38; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'here': 0.66; 'yes!': 0.91 Date: Tue, 5 Jul 2011 07:30:30 -0800 From: Tim Johnson To: python-list@python.org Subject: Re: Testing if a global is defined in a module References: <3dc7e7a8-9a90-499a-b544-bb9969d9ab55@t5g2000yqj.googlegroups.com> <4e124916$0$29970$c3e8da3$5496439d@news.astraweb.com> <4e124db1$0$29973$c3e8da3$5496439d@news.astraweb.com> <20110705000131.GN1971@johnsons-web.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: AkWebsoft User-Agent: Mutt/1.5.20 (2009-06-14) 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1309879699 news.xs4all.nl 21833 [2001:888:2000:d::a6]:60410 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:8839 * Ian Kelly [110704 20:37]: > > It sounds like what you really want is to detect the names *exported* > by the module, then. i Yes! > Why not do it the same way Python does it? If > the module defines an "__all__" attribute, then it is taken to be a > sequence of strings which are the exported names. Otherwise, the > exported names are taken to be all the names in the module dict that > don't begin with an underscore. :) Oh here we go again. Another python feature I didn't know about or have forgotten. Thanks very much for that. Good tip -- Tim tim at johnsons-web dot com or akwebsoft dot com http://www.akwebsoft.com