[GRASS-dev] Re: 'g.gui wxpython' won't work in wingrass as wxgui is a shell script

Ivan Shmakov ivan at theory.asu.ru
Wed Mar 19 13:52:07 EDT 2008

>>>>> Ivan Shmakov <ivan at theory.asu.ru> writes:
>>>>> Michael Barton <michael.barton at asu.edu> writes:


 >> What this means is that we need to have Python people volunteer to
 >> begin to rewrite existing Bash scripts in Python and begin writing
 >> any new scripts in that platform so that we can have the critical
 >> mass to encourage others to learn it and write in it. A couple
 >> people have started on this.

 > I'm afraid that an attempt to rewrite /all/ the Shell scripts in
 > Python will both take time and bring some mess along.  Would you,
 > e. g., consider an untested 100-lines Python substitute for a
 > 50-lines Shell script (that's known to be working for years) to
 > encourage anyone to write in Python?

 > If there're particular strong points of Python, they're to be
 > exploited first (is wxPython among the others?)

	I may sound obvious here, but one more strong point could be
	added almost for free by exploiting an extended G_parser ().
	Namely, in order to ease the creation of ``smart'' wrappers, it
	may be allowed to introspect a GRASS module's CLI from Python.

	Furthermore, with introduction of an additional field, it may be
	allowed for a GRASS module to advertise its ``linearity'' on a
	particular field or fields.  E. g., the following are

$ g.remove rast=foo,bar,baz
$ g.remove rast=foo,bar ; g.remove rast=baz

	Thus a ``smart'' wrapper for `g.remove' should be allowed to run
	`g.remove' on ``chunks'' of a sufficiently large list to
	overcome the OS command line limits (if any.)

	Some ``smart'' wrappers for `g.mlist' and `r.mapcalc' would
	allow for something like:

   for rast in grass.g.mlist (["rast"], "2008-*-temperature"]):
       grass.r.mapcalc ("%s-celsius" % rast, "\"%s\" - 273.15" % rast)

	(BTW, does Python allow associative lists, or named arguments?)

	And there should be a module allowing one to use a Python
	function to perform raster arithmetic (like `r.mapcalc'), too.

	Surely, there're many other things that could be done to make
	Python quite a sophisticated platform for GRASS scripting.  And
	I'm not certain that the time used to rewrite all the existing
	Shell scripts in Python cannot be spent better.

More information about the grass-dev mailing list