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

Johannes Radinger JRadinger at gmx.at
Thu Apr 21 08:18:32 EDT 2011


-------- Original-Nachricht --------
> Datum: Thu, 21 Apr 2011 12:56:29 +0100
> Von: Glynn Clements <glynn at gclements.plus.com>
> An: "Johannes Radinger" <JRadinger at gmx.at>
> CC: grass-user at lists.osgeo.org
> Betreff: Re: [GRASS-user] special python expressions in v.distance

> 
> 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",

Thank you...the leading underscore was the solution to my problem!

/johannes


> 
> 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>

-- 
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit 
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl


More information about the grass-user mailing list