[GRASS-user] GRASS'c Python core function to use as g.mlist

Ricardo Filipe Soares Garcia da ricardo.garcia.silva at gmail.com
Fri Mar 11 09:29:18 EST 2011

Hi Jenny

Long story short: use your command like this (note the asterisk on the
'pattern' variable):

# python code
p=grass.mlist_grouped ('rast', pattern='output*', mapset='Mapping')

I am using the Ipython shell to script grass. It has a cool feature,
that if you type the name of a function followed by two question
marks, you can see the source code of the function (as long as it is
coded in python itself).
So, in doing:


It is possible to see that the mlist_grouped function is internally
calling the 'g.mlist' command with only the 'm' flag.

Reading the documentation for the g.mlist command [1], I realize that,
without using the -r or -e flags, this command accepts wildcards[2] as
the 'pattern' string. The asterisk (*) is the wildcard character for
substituting for any zero or more characters. So, in order to get a
string that starts with 'output' and after that can have anything, you
just type 'output*'

[1] - http://grass.fbk.eu/grass64/manuals/html64_user/g.mlist.html
[2] - http://en.wikipedia.org/wiki/Wildcard_character#Computing

On Fri, Mar 11, 2011 at 12:10 PM, Jenny Turner
<jennyturner1980 at gmail.com> wrote:
> Greetings
> I'm doing a GRASS Python Script where I need to list a set of raster maps
> but I'm not using its exact name but a basic regular expression (r flag in
> g.mlist function).
> So I want to find a list of rasters with output on its name:
> p=grass.mlist_grouped ('rast', pattern='output', mapset='Mapping')
> But I get null entries because no raster map is named output only output01
> output02 output03 ...
> I want to list all raster maps with output on itsd name. How can I do this
> using grass.mlist_grouped?
> Thanks
> Jenny
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user

___________________________ ___ __
Ricardo Garcia Silva

More information about the grass-user mailing list