RapydScript
RapydScript copied to clipboard
Cannot catch ImportError
I'm trying to make a Python program that works in both CPython and RapydScript. The code itself works in both, but it currently needs shlex. If I could catch ImportError, I would just wrap "import shlex" in a try-catch and use a custom shlex.split() if that failed, but "try: ... except ImportError: ..." appears to have no effect.
Hi!
The problem is that RS imports all at compile time. There is async import, this should help:
https://github.com/atsepkov/RapydScript/pull/241
Also you can just make shim-files like common.py and common.pyj that will import lang-specific modules and then use it as
import common
common.shlex.split(...)