Re: [GRASS-dev] error when running v.distance in python script
Hi Anna and Luca, On 19-05-17 15:52, Anna Petrášová wrote: On Fri, May 19, 2017 at 8:50 AM, Paulo van Breugelwrote: Hi devs I am trying to use v.distance in a Python script. However, I am getting the error Module("v.distance", from=tmpout3, to=tmp_val, upload="to_attr", column="x", to_column=column) File "", line 1 Module("v.distance", from=tmpout3, to=tmp_val, upload="to_attr", ^ SyntaxError: invalid syntax If I run the same directly on the command-line it runs without errors. v.distance from=testmap1 to=testmap2 upload=to_attr column=x to_column=lv Is this because 'from' is a reserved word perhaps? If so, how do I use this in a Python script? Otherwise, any idea what I might be doing wrong? Try _from or from_ (I am not sure which one is the right one now). So the underscore the prefix or suffix function as an escape character? It seems to work both if used with grass.script import grass.script as gs gs.run_command("v.distance", from_=tmpout3, to=tmp_val, upload="to_attr", column="x", to_column=column) Both do not seem to work with Module from grass.pygrass.modules import Module Module("v.distance", from_=tmpout3, to=tmp_val, upload="to_attr", column="x", to_column=column) Anna ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev
Re: [GRASS-dev] error when running v.distance in python script
On 19 May 2017 at 15:50, Paulo van Breugelwrote: > Hi devs > Ciao Luca, > I am trying to use v.distance in a Python script. However, I am getting the > error > > Module("v.distance", from=tmpout3, to=tmp_val, upload="to_attr", >column="x", to_column=column) > File "", line 1 > Module("v.distance", from=tmpout3, to=tmp_val, upload="to_attr", > ^ > SyntaxError: invalid syntax > > If I run the same directly on the command-line it runs without errors. > > v.distance from=testmap1 to=testmap2 upload=to_attr column=x to_column=lv > > Is this because 'from' is a reserved word perhaps? If so, how do I use this > in a Python script? Otherwise, any idea what I might be doing wrong? > It could be, try adding underscore ( _ ) before or after the from ( _from or from_ I don't remember ) -- ciao Luca www.lucadelu.org ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev
Re: [GRASS-dev] error when running v.distance in python script
On Fri, May 19, 2017 at 8:50 AM, Paulo van Breugelwrote: > Hi devs > > I am trying to use v.distance in a Python script. However, I am getting the > error > > Module("v.distance", from=tmpout3, to=tmp_val, upload="to_attr", >column="x", to_column=column) > File "", line 1 > Module("v.distance", from=tmpout3, to=tmp_val, upload="to_attr", > ^ > SyntaxError: invalid syntax > > If I run the same directly on the command-line it runs without errors. > > v.distance from=testmap1 to=testmap2 upload=to_attr column=x to_column=lv > > Is this because 'from' is a reserved word perhaps? If so, how do I use this > in a Python script? Otherwise, any idea what I might be doing wrong? Try _from or from_ (I am not sure which one is the right one now). Anna > > > ___ > grass-dev mailing list > grass-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/grass-dev ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev