Skip to content

Commit

Permalink
Added example for import a user-defined Python module
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Nov 27, 2024
1 parent 11cdb34 commit 07b7ca5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/import/fun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test():
print("hello world!")

8 changes: 8 additions & 0 deletions examples/import/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
$sys = PyCore::import('sys');
// Add the directory containing the `fun.py` file to the Python `sys.path`.
$sys->path->append(__DIR__);

$fun = PyCore::import('fun');
$fun->test();

0 comments on commit 07b7ca5

Please sign in to comment.