Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Python path functions #269

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions docs/reference/target-language-details.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2916,9 +2916,29 @@ FIXME: Details needed here.
</ShowIf>
<ShowIf py>

:::warning
FIXME: Details needed here.
:::
A few utility libraries are provided.

- **File Access**

- `lf.source_directory()`: Returns a string giving the full path to the directory containing the `.lf` file of the program.
- `lf.package_directory()`: Returns a string giving the full path to the directory that is the root of the project or package (normally, the directory above the `src` directory).

The above can be used to find supporting files, as shown in the following example:

```lf-py
target Python
preamble {=
import os
=}
main reactor {
state source_path = {= os.path.join(lf.source_directory(), "PythonPaths.lf") =}
reaction(startup) {=
file = open(self.source_path, "r");
print(file.read());
file.close();
=}
}
```

</ShowIf>
<ShowIf ts>
Expand Down
Loading