[GRASS GIS] #3835: v.distance returns a 'Syntax error' when used from python

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[GRASS GIS] #3835: v.distance returns a 'Syntax error' when used from python

GRASS GIS
#3835: v.distance returns a 'Syntax error' when used from python
----------------------+-------------------------
 Reporter:  epifanio  |      Owner:  grass-dev@…
     Type:  defect    |     Status:  new
 Priority:  normal    |  Milestone:
Component:  Vector    |    Version:  svn-trunk
 Keywords:            |        CPU:  x86-64
 Platform:  Linux     |
----------------------+-------------------------
 Trying to run `v.distance` from `grass.script.run_command()` returns a
 syntax error

 {{{
 import grass.script as grass
 grass.run_command('v.db.addcolumn',
     map='points_of_interest',
     columns="distance double precision")

 grass.run_command('v.distance',
                   from='points_of_interest',
                   to='points_of_interest',
                   upload='distance',
                   column='distance')
 File "<ipython-input-9-28b7e4b9716c>", line 2
   from='points_of_interest',
        ^
 SyntaxError: invalid syntax
 }}}

 Tested on:

 GRASS GIS version: grass-ci on github
 {{{
 git rev-parse --short HEAD
 2860974f
 }}}
 GRASS LOCATION: nc_basic_spm_grass7

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3835>
GRASS GIS <https://grass.osgeo.org>


_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev
Reply | Threaded
Open this post in threaded view
|

Re: [GRASS GIS] #3835: v.distance returns a 'Syntax error' when used from python3 (was: v.distance returns a 'Syntax error' when used from python)

GRASS GIS
#3835: v.distance returns a 'Syntax error' when used from python3
-----------------------+-------------------------
  Reporter:  epifanio  |      Owner:  grass-dev@…
      Type:  defect    |     Status:  new
  Priority:  normal    |  Milestone:
 Component:  Vector    |    Version:  svn-trunk
Resolution:            |   Keywords:
       CPU:  x86-64    |   Platform:  Linux
-----------------------+-------------------------

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3835#comment:1>
GRASS GIS <https://grass.osgeo.org>


_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev
Reply | Threaded
Open this post in threaded view
|

Re: [GRASS GIS] #3835: v.distance returns a 'Syntax error' when used from python (was: v.distance returns a 'Syntax error' when used from python3)

GRASS GIS
In reply to this post by GRASS GIS
#3835: v.distance returns a 'Syntax error' when used from python
-----------------------+-------------------------
  Reporter:  epifanio  |      Owner:  grass-dev@…
      Type:  defect    |     Status:  new
  Priority:  normal    |  Milestone:
 Component:  Vector    |    Version:  svn-trunk
Resolution:            |   Keywords:
       CPU:  x86-64    |   Platform:  Linux
-----------------------+-------------------------

Comment (by epifanio):

 The issue affect both python2 and python3

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3835#comment:2>
GRASS GIS <https://grass.osgeo.org>


_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev
Reply | Threaded
Open this post in threaded view
|

Re: [GRASS GIS] #3835: v.distance returns a 'Syntax error' when used from python

GRASS GIS
In reply to this post by GRASS GIS
#3835: v.distance returns a 'Syntax error' when used from python
-----------------------+-------------------------
  Reporter:  epifanio  |      Owner:  grass-dev@…
      Type:  defect    |     Status:  new
  Priority:  normal    |  Milestone:
 Component:  Vector    |    Version:  svn-trunk
Resolution:            |   Keywords:
       CPU:  x86-64    |   Platform:  Linux
-----------------------+-------------------------

Comment (by lucadelu):

 Try to use `from_`

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3835#comment:3>
GRASS GIS <https://grass.osgeo.org>


_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev
Reply | Threaded
Open this post in threaded view
|

Re: [GRASS GIS] #3835: v.distance returns a 'Syntax error' when used from python

GRASS GIS
In reply to this post by GRASS GIS
#3835: v.distance returns a 'Syntax error' when used from python
-----------------------+-------------------------
  Reporter:  epifanio  |      Owner:  grass-dev@…
      Type:  defect    |     Status:  new
  Priority:  normal    |  Milestone:
 Component:  Vector    |    Version:  svn-trunk
Resolution:            |   Keywords:
       CPU:  x86-64    |   Platform:  Linux
-----------------------+-------------------------

Comment (by pmav99):

 {{{from}}} is a Python
 "[https://github.com/python/cpython/blob/3.7/Lib/keyword.py#L15-L53
 keyword]". This means that the Python parser does not allow them to be
 used as identifier names (functions, classes, variables, parameters etc).
 If memory serves, when a module argument/option is a Python keyword, then
 the python wrapper appends an underscore to its name. I.e. you need to
 replace {{{from}}} with {{{from_}}} like @lucadelu suggested.

 FYI, there are a few different keywords between python 2 and 3 but for the
 most part they are the same. E.g. in Python 2, {{{print}}} used to be  a
 statement (i.e. a keyword), while in Python 3 it got converted to a
 function.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3835#comment:4>
GRASS GIS <https://grass.osgeo.org>


_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev
Reply | Threaded
Open this post in threaded view
|

Re: [GRASS GIS] #3835: v.distance returns a 'Syntax error' when used from python

GRASS GIS
In reply to this post by GRASS GIS
#3835: v.distance returns a 'Syntax error' when used from python
-----------------------+-------------------------
  Reporter:  epifanio  |      Owner:  grass-dev@…
      Type:  defect    |     Status:  closed
  Priority:  normal    |  Milestone:
 Component:  Vector    |    Version:  svn-trunk
Resolution:  invalid   |   Keywords:
       CPU:  x86-64    |   Platform:  Linux
-----------------------+-------------------------
Changes (by sbl):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 OK to close, right?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3835#comment:5>
GRASS GIS <https://grass.osgeo.org>


_______________________________________________
grass-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-dev