[GRASS-dev] Python scripts in GRASS GIS: conditional loading of external libraries?

Markus Neteler neteler at osgeo.org
Fri Oct 19 07:45:29 PDT 2018


we are currently writing a Python script which needs to import some
heavy external libraries.
AFAIK the script is read twice, once by the Python interpreter, then
when having reached the grass.parser() line again in order to re-read
properly the
#% options ...
etc. statements.

Now: could the import of the external library (it takes in the range
of > 2min) be conditionalized to only be read at the second "run"?

I was searching in the g.parser code but didn't really find anything useful.
An example would also be fine (addon?).

Or am I on the wrong track?


More information about the grass-dev mailing list