[GRASS-user] special python expressions in v.distance

Glynn Clements glynn at gclements.plus.com
Thu Apr 21 07:56:29 EDT 2011


Johannes Radinger wrote:

> I want to use v.distance in a pyton script.
> 
> I try:
>     grass.run_command("v.distance",
>                       flags="o",
>                       from="points",
>                       to="line",
>                       upload="to_x,to_y",
>                       col="to_X,to_Y")
> 
> but I fail because the expression FROM is already
> used by python...
> 
> what is the correct way to handle that problem?

Add a leading underscore:

	_from="points",

If the first character of a keyword is an underscore, it's removed
when generating the argument list. This allows passing arguments which
are Python keywords or which are recognised by the run_command()
function.

Most arguments which are recognised by the Popen() constructor are
passed to Popen() rather than to the program. The argument names
"flags", "overwrite", "quiet" and "verbose" are also treated
specially.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list