mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: improve the examples/call_v_from_python with Python showing the result of the calculation done on the V side
This commit is contained in:
parent
409a4f33a1
commit
7302d8c4a8
@ -1,5 +1,5 @@
|
||||
A simple example to show how to call a function written in v from python
|
||||
|
||||
Step 1: Compile the v code to a shared library using ``v -shared -prod test.v``
|
||||
Step 1: Compile the v code to a shared library using `v -shared test.v`
|
||||
|
||||
Step 2: Run the python file using ``python3 test.py``
|
||||
Step 2: Run the python file using `python3 test.py`
|
||||
|
@ -5,6 +5,7 @@ so_file="./test.so"
|
||||
if os.name=="nt":
|
||||
so_file="./test.dll"
|
||||
lib = CDLL(so_file)
|
||||
print("lib.square(10) result is", lib.square(10))
|
||||
assert lib.square(10) == 100, "Cannot validate V square()."
|
||||
|
||||
lib.sqrt_of_sum_of_squares.restype = c_double
|
||||
|
Loading…
Reference in New Issue
Block a user