Mercurial > pymonkey
diff docs/src/pymonkey.txt @ 111:df607254de2d
Added a doctest.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 16 Aug 2009 21:09:21 -0700 |
parents | c41f1d2e8f9d |
children | 2086377c0abe |
line wrap: on
line diff
--- a/docs/src/pymonkey.txt Sun Aug 16 13:50:42 2009 -0700 +++ b/docs/src/pymonkey.txt Sun Aug 16 21:09:21 2009 -0700 @@ -94,6 +94,16 @@ The third argument is a tuple containing the arguments passed to the function. + For instance: + + >>> def add(cx, this, args): + ... return args[0] + args[1] + >>> cx = pymonkey.Runtime().new_context() + >>> obj = cx.new_object() + >>> cx.define_property(obj, 'add', cx.new_function(add, 'add')) + >>> cx.evaluate_script(obj, 'add(1, 1);', '<string>', 1) + 2 + .. method:: get_object_private(object) Returns the ``private_obj`` passed to :meth:`new_object()`