Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9363
| References | <4e0d4d30$0$29990$c3e8da3$5496439d@news.astraweb.com> <mailman.546.1309543383.1164.python-list@python.org> <2942f134-6c38-4a43-9322-b053ae61a14b@gc3g2000vbb.googlegroups.com> |
|---|---|
| Date | 2011-07-13 14:20 +1000 |
| Subject | Re: Enhanced dir() function |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.958.1310530845.1164.python-list@python.org> (permalink) |
On Wed, Jul 13, 2011 at 7:46 AM, rantingrick <rantingrick@gmail.com> 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.)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Enhanced dir() function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-01 14:29 +1000
Re: Enhanced dir() function Tim Chase <python.list@tim.thechases.com> - 2011-07-01 12:20 -0500
Re: Enhanced dir() function Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-02 04:32 +1000
Re: Enhanced dir() function rantingrick <rantingrick@gmail.com> - 2011-07-12 14:46 -0700
Re: Enhanced dir() function Chris Angelico <rosuav@gmail.com> - 2011-07-13 14:20 +1000
Re: Enhanced dir() function Ethan Furman <ethan@stoneleaf.us> - 2011-07-01 11:40 -0700
Re: Enhanced dir() function Ethan Furman <ethan@stoneleaf.us> - 2011-07-12 14:19 -0700
Re: Enhanced dir() function rantingrick <rantingrick@gmail.com> - 2011-07-12 14:38 -0700
csiph-web