summaryrefslogtreecommitdiff
path: root/scipy/weave/examples/object.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-01-02 08:26:24 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-01-02 08:26:24 +0000
commit4712a37b93832933a46376ee99339f9040ba3670 (patch)
tree8a3de8500925061b0f2368fae2d50159dbea206f /scipy/weave/examples/object.py
parentb5ba0003def4cfa43b29d29df8f085d09609707b (diff)
downloadnumpy-4712a37b93832933a46376ee99339f9040ba3670.tar.gz
Moved weave to scipy
Diffstat (limited to 'scipy/weave/examples/object.py')
-rw-r--r--scipy/weave/examples/object.py51
1 files changed, 0 insertions, 51 deletions
diff --git a/scipy/weave/examples/object.py b/scipy/weave/examples/object.py
deleted file mode 100644
index 286591613..000000000
--- a/scipy/weave/examples/object.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# h:\wrk\scipy\weave\examples>python object.py
-# initial val: 1
-# inc result: 2
-# after set attr: 5
-
-import scipy.weave as weave
-
-#----------------------------------------------------------------------------
-# get/set attribute and call methods example
-#----------------------------------------------------------------------------
-
-class foo:
- def __init__(self):
- self.val = 1
- def inc(self,amount):
- self.val += 1
- return self.val
-obj = foo()
-code = """
- int i = obj.attr("val");
- std::cout << "initial val: " << i << std::endl;
-
- py::tuple args(1);
- args[0] = 2;
- i = obj.mcall("inc",args);
- std::cout << "inc result: " << i << std::endl;
-
- obj.set_attr("val",5);
- i = obj.attr("val");
- std::cout << "after set attr: " << i << std::endl;
- """
-weave.inline(code,['obj'])
-
-#----------------------------------------------------------------------------
-# indexing of values.
-#----------------------------------------------------------------------------
-from UserList import UserList
-obj = UserList([1,[1,2],"hello"])
-code = """
- int i;
- // find obj length and accesss each of its items
- std::cout << "UserList items: ";
- for(i = 0; i < obj.length(); i++)
- std::cout << obj[i] << " ";
- std::cout << std::endl;
- // assign new values to each of its items
- for(i = 0; i < obj.length(); i++)
- obj[i] = "goodbye";
- """
-weave.inline(code,['obj'])
-print "obj with new values:", obj