[GRASS-dev] grass.info versus print

Glynn Clements glynn at gclements.plus.com
Thu Apr 21 05:37:59 PDT 2016


Vaclav Petras wrote:

> Perhaps I was not completely clear before. I agree with Glynn.
> grass.script.message() etc. for messages. print()/sys.stdout for text
> output (e.g. tables).

In short: g.message for "messages", print or sys.stdout.write() for
"data".

The reason why Unix has stdout and stderr is so that you can redirect
stdout to a file which having stderr associated with the terminal. So
messages intended for the user don't interfere with parsing the data,
and redirecting the data to the file doesn't hide messages from the
user.

So, assuming that the two streams will be separated should provide
some clues as to which is appropriate for any given case.

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


More information about the grass-dev mailing list