-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpython.qs
More file actions
35 lines (28 loc) · 859 Bytes
/
Copy pathpython.qs
File metadata and controls
35 lines (28 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Python interop demo
# Note: Requires building with Python support: .\build.ps1 -WithPython
try {
python_init()
print("Python initialized")
# Evaluate Python code
python_eval("import math")
result = python_eval("math.sqrt(144)")
print("sqrt(144):", result)
# Get Python attribute
pi = python_get("math", "pi")
print("pi:", pi)
# Call Python function
result = python_eval("abs(-42)")
print("abs(-42):", result)
# Python string operations
result = python_eval("'hello'.upper()")
print("upper:", result)
# Python list operations
result = python_eval("[x**2 for x in range(5)]")
print("squares:", result)
# Finalize Python
python_finalize()
print("Python finalized")
} oops {
print("Python support not tryavailable")
print("Build with: .\build.ps1 -WithPython")
}