Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'plenty': 0.04; 'args': 0.05; '#define': 0.09; '>>>>': 0.09; 'wed,': 0.12; 'am,': 0.13; 'wrote:': 0.15; 'advocating': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'rantingrick': 0.16; 'subject:() ': 0.16; 'subject:function': 0.16; 'received:209.85.210.174': 0.19; 'received:mail-iy0-f174.google.com': 0.19; 'header:In-Reply- To:1': 0.22; 'once.': 0.23; 'problem?': 0.23; 'code': 0.24; 'message-id:@mail.gmail.com': 0.28; 'granted,': 0.30; 'to:addr :python-list': 0.34; 'there': 0.34; '(for': 0.36; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'room': 0.38; 'run': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'your': 0.60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=3/CLnJaOjSvph4F38U8WPdGbO8fDZfGdVIO3d49ea0Q=; b=BustsrYSI0DRhT0cUtJbzcaoti3OceUx7vXSt0eKCzhmvM59FXsPkiemIbSjUcb+nw Ygot6WIX8TQbengeIhWmFEy6FsJSjdVZ2vYNai00v0xm+CdTMjtRD9LGS1r/HLpXGpTJ Y1WP1x5pDtMJxmCj6aHpQ2/lo88q47fDzM2T8= MIME-Version: 1.0 In-Reply-To: <2942f134-6c38-4a43-9322-b053ae61a14b@gc3g2000vbb.googlegroups.com> References: <4e0d4d30$0$29990$c3e8da3$5496439d@news.astraweb.com> <2942f134-6c38-4a43-9322-b053ae61a14b@gc3g2000vbb.googlegroups.com> Date: Wed, 13 Jul 2011 14:20:42 +1000 Subject: Re: Enhanced dir() function From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 1310530845 news.xs4all.nl 23952 [2001:888:2000:d::a6]:53963 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:9363 On Wed, Jul 13, 2011 at 7:46 AM, rantingrick wrote: >>>> [x for x in dir([]) if not x.startswith('_')] > ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', > 'reverse', 'sort'] > > Because we have plenty of room for args in this function... > >>>> dir(verbose=False) > ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', > 'reverse', 'sort'] > #define my_dir(o,verbose) verbose?dir(o):[x for x in dir(o) if not x.startswith('_')] And there you are, out of your difficulty at once. Granted, you now have to run your code through cpp, but is that so big a problem? ChrisA (For the sarcasm-impaired: I am NOT advocating this.)