Created
July 1, 2013 15:14
-
-
Save olemb/5901717 to your computer and use it in GitHub Desktop.
A version of dir() which lists only public attributes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This goes in the PYTHONSTARTUP file. | |
Example: | |
>>> pubdir([]) | |
['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] | |
""" | |
__pubdir_no_arg = [] | |
def pubdir(obj=__pubdir_no_arg): | |
if obj is __pubdir_no_arg: | |
attributes = dir() | |
else: | |
attributes = dir(obj) | |
return [a for a in attributes if not a.startswith('_')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment