-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export nim-object-proc link during call from nim #180
Comments
Ok, looks like I found the same issue, so the question is:
Thank you, |
|
|
import nimpy
type
NimObj = ref object
x: int
proc fn1(o: NimObj, x: int) =
o.x.inc(x)
pyGlobals()["fn1"] = fn1 # Add function to python globals
discard pyBuiltinsModule().exec """
class MyClass:
def method1(self, obj):
fn1(obj, 1)
"""
let obj = NimObj()
let MyClass = pyGlobals()["MyClass"].to(proc():PyObject) # Get MyClass constructor from globals
let c = MyClass()
discard c.method1(obj)
discard c.method1(obj)
echo obj.x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Is it possible to export object type and its function into python, but without using precompiled module?
Here is an example, which works, but I put comment there:
My next idea is to export nim-class somehow, and in python use the following:
The text was updated successfully, but these errors were encountered: