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

GRASS GIS trac at osgeo.org
Tue Apr 30 07:36:15 PDT 2019


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



More information about the grass-dev mailing list