[GRASS-dev] Python scripts in GRASS GIS: conditional loading of external libraries?
Markus Neteler
neteler at osgeo.org
Tue Oct 30 01:45:39 PDT 2018
Hi,
On Fri, Oct 19, 2018 at 5:18 PM Martin Landa <landa.martin at gmail.com> wrote:
> pá 19. 10. 2018 v 16:45 odesílatel Markus Neteler <neteler at osgeo.org> napsal:
> > we are currently writing a Python script which needs to import some
> > heavy external libraries.
>
> if I understand well, a lazy import could help
>
> """
> def main:
> from mylib import xyz
> ...
>
> return 0
>
> if __name__ == "__main__":
> opt, flg = grass.parser()
> sys.exit(main())
> """
yes, this approach works nicely.
Thanks!
Markus
More information about the grass-dev
mailing list