Skip to content

Commit

Permalink
ENH: add BagObj.__dir__ to numpy.lib.npyio
Browse files Browse the repository at this point in the history
This allows dir(bagobj), and also enables tab-completion on a BagObj,
which can be useful in an interpreter or IPython
  • Loading branch information
wwendell committed Nov 18, 2014
1 parent c2d7845 commit 60de33d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions numpy/lib/npyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ def __getattribute__(self, key):
return object.__getattribute__(self, '_obj')[key]
except KeyError:
raise AttributeError(key)

def __dir__(self):
"""
Enables dir(bagobj) to list the files in an NpzFile.
This also enables tab-completion in an interpreter or IPython.
"""
return object.__getattribute__(self, '_obj').keys()


def zipfile_factory(*args, **kwargs):
Expand Down

0 comments on commit 60de33d

Please sign in to comment.