1
0
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:
Delyan Angelov 2022-10-16 22:48:00 +03:00
parent 409a4f33a1
commit 7302d8c4a8
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 3 additions and 2 deletions

View File

@ -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`

View File

@ -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