[GRASS-dev] New wiki page summarising GRASS APIs
Glynn Clements
glynn at gclements.plus.com
Sun Feb 1 03:29:20 PST 2015
Pietro wrote:
> {{{
> import os
> os.system('g.region rast=elevation')
> }}}
>
> and not subprocess:
>
> {{{
> import subprocess
> subprocess.call('g.region rast=elevation', shell=True)
>
> # or
>
> subprocess.Popen('g.region rast=elevation', shell=True)
> }}}
>
> Concerning the pygrass Module API, may be we can use the shortcut version:
Using subprocess.call() with shell=True is no better than using
os.system(). Both should be avoided at all costs.
The grass.script module provides a number of convenience functions
which use grass.script.make_command() to generate the command's
argument list from the function's argument list. Also, they use a
version of subprocess.Popen() which has been wrapped to deal with some
of Windows' idiosyncrasies.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list