comparison docs/rendered/_sources/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
comparison
equal deleted inserted replaced
110:699d03db6614 111:df607254de2d
92 value of ``this`` for the duration of the call. 92 value of ``this`` for the duration of the call.
93 93
94 The third argument is a tuple containing the arguments 94 The third argument is a tuple containing the arguments
95 passed to the function. 95 passed to the function.
96 96
97 For instance:
98
99 >>> def add(cx, this, args):
100 ... return args[0] + args[1]
101 >>> cx = pymonkey.Runtime().new_context()
102 >>> obj = cx.new_object()
103 >>> cx.define_property(obj, 'add', cx.new_function(add, 'add'))
104 >>> cx.evaluate_script(obj, 'add(1, 1);', '<string>', 1)
105 2
106
97 .. method:: get_object_private(object) 107 .. method:: get_object_private(object)
98 108
99 Returns the ``private_obj`` passed to :meth:`new_object()` 109 Returns the ``private_obj`` passed to :meth:`new_object()`
100 when `object` was first created. If it doesn't exist, ``None`` 110 when `object` was first created. If it doesn't exist, ``None``
101 is returned. 111 is returned.