RapydScript icon indicating copy to clipboard operation
RapydScript copied to clipboard

Cannot catch ImportError

Open kj7rrv opened this issue 5 years ago • 2 comments

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.

kj7rrv avatar Dec 14 '20 19:12 kj7rrv

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

valq7711 avatar Dec 15 '20 05:12 valq7711

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(...)

valq7711 avatar Dec 15 '20 05:12 valq7711