[Numpy-svn] r8452 - trunk/numpy/lib
numpy-svn at scipy.org
numpy-svn at scipy.org
Wed Jun 2 09:07:41 EDT 2010
Author: rgommers
Date: 2010-06-02 08:07:41 -0500 (Wed, 02 Jun 2010)
New Revision: 8452
Modified:
trunk/numpy/lib/npyio.py
Log:
DOC: merge wiki edits for module npyio.
Modified: trunk/numpy/lib/npyio.py
===================================================================
--- trunk/numpy/lib/npyio.py 2010-06-02 13:07:25 UTC (rev 8451)
+++ trunk/numpy/lib/npyio.py 2010-06-02 13:07:41 UTC (rev 8452)
@@ -75,23 +75,29 @@
"""
BagObj(obj)
- Convert attribute lookups to getitems on the object passed in.
+ Convert attribute look-ups to getitems on the object passed in.
Parameters
----------
obj : class instance
- Object on which attribute lookup is performed.
+ Object on which attribute look-up is performed.
Examples
--------
+ >>> from numpy.lib.npyio import BagObj as BO
>>> class BagDemo(object):
- ... def __getitem__(self, key):
- ... return key
+ ... def __getitem__(self, key): # An instance of BagObj(BagDemo)
+ ... # will call this method when any
+ ... # attribute look-up is required
+ ... result = "Doesn't matter what you want, "
+ ... return result + "you're gonna get this"
...
>>> demo_obj = BagDemo()
- >>> bagobj = np.lib.npyio.BagObj(demo_obj)
- >>> bagobj.some_item
- 'some_item'
+ >>> bagobj = BO(demo_obj)
+ >>> bagobj.hello_there
+ "Doesn't matter what you want, you're gonna get this"
+ >>> bagobj.I_can_be_anything
+ "Doesn't matter what you want, you're gonna get this"
"""
def __init__(self, obj):
@@ -147,7 +153,7 @@
>>> outfile.seek(0)
>>> npz = np.load(outfile)
- >>> isinstance(npz, np.lib.npyio.NpzFile)
+ >>> isinstance(npz, np.lib.io.NpzFile)
True
>>> npz.files
['y', 'x']
More information about the Numpy-svn
mailing list