How to make Transcrypt skip a line (without "try")?

52 Views Asked by At

The program I write should be able to run both directly via the interpreter and via Transcrypt. The problem is that I need to skip some lines when Transcrypt is running and "try" does not work in Transcrypt. Is there any other way to skip lines when running the program via Transcypt? Is it possible to use if ?:

if transctypt is activated:

Thanks in advance!

2

There are 2 best solutions below

0
Rickard Hultgren On BEST ANSWER

Thanks to the fzzylogic's comment I solved the problem like this:

from org.transcrypt.stubs.browser import __pragma__

#__pragma__('skip')
import subprocess
import os
#__pragma__('noskip')
0
AKX On

If there's no built-in method otherwise, you could probably e. g. look for the existence of the document variable. There should be no such thing when not running in the browser. (I haven't tested this.)

try:
  assert document
  in_transcrypt = True
except Exception:
  in_transcrypt = False