Enhanced dir() function

Chris Angelico rosuav at gmail.com
Wed Jul 13 00:20:42 EDT 2011


On Wed, Jul 13, 2011 at 7:46 AM, rantingrick <rantingrick at 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.)



More information about the Python-list mailing list