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

Martin Landa landa.martin at gmail.com
Fri Oct 19 08:17:53 PDT 2018


Hi,

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

Martin

-- 
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa


More information about the grass-dev mailing list