Description Usage Arguments Value Author(s) Examples
py.call
calls a Python callable - usually a function, built-in,
method or a class object.
1 |
callable |
Reference to a Python object that is callable |
... |
arguments to pass to the object |
.ref |
logical, if |
Result of the call.
Simon Urbanek
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | py.init()
## create a simple class
py.eval("class foo:
def __init__(self, value=0):
self.x = value
def f(self):
self.x = self.x + 1
return self.x")
## get the class object
foo = py.get("foo")
foo
## create an instance by calling it
i = py.call(foo)
i
i$f()
i$f()
i$x
i$x = 20
i$f()
## another instance with pre-set value
j = py.call(foo, 40)
j$x
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.