[GRASS-dev] Error running g.rename from python
osgis.dev at gmail.com
Sun Oct 12 21:41:20 PDT 2014
Thanks Markus and Glynn,
This worked g.parse_command("g.rename", rast=(old_name,new_name))
Yes I used the development version of GRASS GIS 7 and by using Python tuple
as suggested by Glynn, the command was able to batch rename my files.
On Fri, Oct 10, 2014 at 1:23 PM, Glynn Clements <glynn at gclements.plus.com>
> Erick Opiyo wrote:
> > Initially I was able to batch rename files in grassdb using the command
> > listed below
> > g.parse_command("g.rename",rast=old_name,new_name)
> > But now I keep getting this error:
> > SyntaxError: non-keyword arg after keyword arg
> > What could be the issue?
> g.parse_command("g.rename", rast=old_name, new_name)
> is a function call with three arguments:
> 1. "g.rename"
> 2. rast=old_name
> 3. new_name
> The second argument is a keyword argument, the first and third are
> positional (non-keyword) arguments. Python doesn't allow positional
> arguments to follow keyword arguments; positional arguments come
> first, keyword arguments last.
> Given the context, it's safe to assume that you want to pass a pair of
> map names as the value to the rast= option. This requires explicit
> parentheses so that the comma is treated as forming a tuple rather
> than as an argument separator:
> g.parse_command("g.rename", rast=(old_name,new_name))
> The parentheses in a tuple value can only be omitted if it doesn't
> result in the comma being ambiguous (as is the case in a function
> Glynn Clements <glynn at gclements.plus.com>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the grass-dev