Skip to content

Commit b7ad94f

Browse files
committed
tmp
1 parent 44ea629 commit b7ad94f

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

examples/expr3.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
def main0():
2+
n: i32 = 5
3+
m: i32 = fun_from_py_module(n)
4+
print("hi")
5+
print("m recieved is: ", m)
6+
print("this time value received is:", fun_from_py_module(-22))
7+
print("And this time value received is:", fun_from_py_module(101))
8+
9+
print("cpython_average(2, 3): ", cpython_average(2, 3))
10+
print("cpython_average(-100, -1): ", cpython_average(-100, -1))
11+
12+
cpython_print_str("hi how are you?")
13+
pqr: str = "abcdefgh"
14+
cpython_print_str("hi how are you?: " + pqr)
15+
16+
abc: str = cpython_return_random_str()
17+
print("abc: ", abc)
18+
19+
print(cpython_str_concat(abc, pqr))
20+
21+
@pythoncall(module="py_module")
22+
def cpython_str_concat(a: str, b: str)->str:
23+
pass
24+
25+
@pythoncall(module="py_module")
26+
def fun_from_py_module(n: i32) -> i32:
27+
pass
28+
29+
@pythoncall(module="py_module")
30+
def cpython_average(n: i32, m: i32) -> f64:
31+
pass
32+
33+
@pythoncall(module="py_module")
34+
def cpython_print_str(x: str):
35+
pass
36+
37+
@pythoncall(module="py_module")
38+
def cpython_return_random_str() -> str:
39+
pass
40+
41+
main0()

py_module.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def fun_from_py_module(n):
2+
import os
3+
print(os.getcwd())
4+
print("hi from cpython", n)
5+
return n + 2
6+
7+
def cpython_average(n, m):
8+
return (m + n) / 3
9+
10+
def cpython_print_str(x: str):
11+
print("I received the string:", x)
12+
13+
def cpython_return_random_str() -> str:
14+
return "this is some string"
15+
16+
def cpython_str_concat(a: str, b: str)->str:
17+
return "concatenated: " + a + " " + b

0 commit comments

Comments
 (0)