[GRASS-user] A Py-script where I check group and delete

Glynn Clements glynn at gclements.plus.com
Fri Oct 1 13:52:38 EDT 2010


Luisa Peña wrote:

> I have a Python-script where I create a group (using i.group) but, if the
> group already exists I need to eliminate (g.remove).
> 
> My question is: How can I check, using Python Script code, if a group
> already exists?

	import grass.script as grass

	if grass.find_file(groupname, 'group)['file']:
	    ...

Or you could just call g.remove anyhow, e.g.

	grass.run_command('g.remove',
	                  group = groupname,
                          stderr = file(os.devnull, 'w+'))

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list