Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hello,

I want to use rustpython as my scripting engine, but with some simple syntax extension. I want to do it with a preprocessor, so that I don't need to modify rustpython's parser.

I can ask users to name their source code with a special extension name to indicate that the file contains extended syntax. For example, test.py is a normal python file, and test.mypy is an extended python file.

if it is an extended python file, I will first run my preprocessor to translate it into a normal python and then run rustpython.

But if the mypy file imports another mypy file, how can I run the preprocessor before importing?

An idea is using the import hook as mentioned here https://aroberge.github.io/ideas/docs/html/

I wonder if this can be achieved using rustpython? i.e. is there a callback right before importing a file so that I can intercept and modify the imported code.

Thanks.

You must be logged in to vote

Replies: 1 comment

Comment options

RustPython supports a lot of features of importlib. The projects looks like using importlib. It will be worth to try.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.