Python binding

I try to call Swift from Python which doesn't work because of name mangling.

bla.swift compiled with swiftc -emit-library to libbla.so:

public func bla() {
print("Bla")
}

bla.py:

import ctypes
lib = ctypes.cdll.LoadLibrary("./libbla.so")
#print(lib.$s3blaAAyyF) <- doesn't work because of the dollar sign

What is the preferred way to do this?

https://docs.python.org/3/library/ctypes.html

1 Like

Cool, I haven't seen this. Thanks.