<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
    <br>
    <br>
    <div class="moz-cite-prefix">On 14-04-16 14:27, Vaclav Petras wrote:<br>
    </div>
    <blockquote
cite="mid:CABo5uVtFaC_+3GWKgL+SyatRMvpAWL7KMriv_6_DrRAzNPumSg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On Thu, Apr 14, 2016 at 7:33 AM,
            Paulo van Breugel <span dir="ltr"><<a
                moz-do-not-send="true"
                href="mailto:p.vanbreugel@gmail.com" target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:p.vanbreugel@gmail.com">p.vanbreugel@gmail.com</a></a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex"><span class="">On Thu,
                Apr 14, 2016 at 1:04 PM, Glynn Clements <span dir="ltr"><<a
                    moz-do-not-send="true"
                    href="mailto:glynn@gclements.plus.com"
                    target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a></a>></span>
                wrote:<br>
                <blockquote class="gmail_quote" style="margin:0px 0px
                  0px 0.8ex;border-left:1px solid
                  rgb(204,204,204);padding-left:1ex"><span>
                  </span><br>
                  In general, scripts should use the g.message wrappers
                  rather than<br>
                  Python's "print" statement or os.write(), as that will
                  honour any<br>
                  configuration options (GRASS_VERBOSE,
                  GRASS_MESSAGE_FORMAT,<br>
                  --quiet/--verbose, etc).<br>
                </blockquote>
                <div><br>
                </div>
              </span>
              <div>Thanks Glynn. It seems there are different opinions,
                see earlier comment from Vaclav.</div>
            </blockquote>
            <div><br>
            </div>
            <div>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).<br>
            </div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">
              <div>Also in the examples on the Wiki (e.g., on <a
                  moz-do-not-send="true"
                  href="https://grasswiki.osgeo.org/wiki/GRASS_and_Python"
                  target="_blank"><a class="moz-txt-link-freetext" href="https://grasswiki.osgeo.org/wiki/GRASS_and_Python">https://grasswiki.osgeo.org/wiki/GRASS_and_Python</a></a>)
                and various addons I have looked at, I can see both
                being used.</div>
            </blockquote>
            <div><br>
            </div>
            <div>I would have to go through the individual examples but
              sometimes it might be be clear what is a message to inform
              user about something and what is a text output of the
              module. A rule of thumb can be that modules which output
              maps, (usually) don't do text output, so they shouldn't
              use print().<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    In this case (r.vif) the output is not a map, but a list of values,
    i.e., text output (see below). Based on the guidelines, I would
    assume I should use print()? <br>
    <br>
    <pre>All variables</pre>
    <pre>----------------------------------------</pre>
    <pre>variable                           vif      sqrtvif</pre>
    <pre>2000_01_precip@climate_1970_2012       2.30     1.52</pre>
    <pre>2000_03_tempmean@climate_1970_2012    24.95     5.00</pre>
    <pre>2000_11_precip@climate_1970_2012       3.54     1.88</pre>
    <pre>2001_02_precip@climate_1970_2012       4.55     2.13</pre>
    <pre>2001_04_tempmean@climate_1970_2012    25.01     5.00</pre>
    <pre>
Variable '2001_04_tempmean@climate_1970_2012' removed</pre>
    <pre>----------------------------------------</pre>
    <pre>variable                           vif      sqrtvif</pre>
    <pre>2000_01_precip@climate_1970_2012       2.30     1.52</pre>
    <pre>2000_03_tempmean@climate_1970_2012     2.19     1.48</pre>
    <pre>2000_11_precip@climate_1970_2012       3.48     1.87</pre>
    <pre>2001_02_precip@climate_1970_2012       4.54     2.13</pre>
    <pre>
Final selected variables are: 2000_01_precip, 2000_03_tempmean, 2000_11_precip, 2001_02_precip</pre>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <pre class="western" style="margin-bottom: 0.5cm"><tt>with as maximum VIF: 5.69787583189</tt></pre>
    <title></title>
    <meta name="generator" content="LibreOffice 5.1.1.1 (Linux)">
    <style type="text/css">
                @page { margin: 2cm }
                pre { color: #000000; line-height: 110% }
                pre.western { font-family: "LM Mono Prop Light 10"; font-size: 9pt; so-language: en-US; font-weight: normal }
                pre.cjk { font-family: "HG Mincho Light J", "MS Mincho", "HG Mincho J", "HG Mincho L", "HG Mincho", "Mincho", "MS PMincho", "MS Gothic", "HG Gothic J", "HG Gothic B", "HG Gothic", "Gothic", "MS PGothic", "Andale Sans UI", "Arial Unicode MS", "Lucida Sans Unicode", "Tahoma"; font-size: 12pt }
                pre.ctl { font-family: "Arial Unicode MS"; font-size: 12pt }
                p { margin-bottom: 0.21cm; color: #000000; line-height: 120%; text-align: justify; orphans: 2; widows: 2 }
                p.western { font-family: "Thorndale", serif; font-size: 11pt; so-language: en-US }
                a.western:visited { so-language: en-US }
                a.cjk:visited { so-language: en-US }
                a.ctl:visited { so-language: en-US </style><br>
    <br>
    <blockquote
cite="mid:CABo5uVtFaC_+3GWKgL+SyatRMvpAWL7KMriv_6_DrRAzNPumSg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div><br>
            </div>
            <div>Also for you personal scripts, you are free to use any
              solution you want. That might be what the examples are
              showing. However, Python scripts which are modules, for
              example in Addons, should adhere to the submitting
              guidelines:<br>
              <br>
              <a moz-do-not-send="true"
                href="https://trac.osgeo.org/grass/wiki/Submitting/Python#Messages">https://trac.osgeo.org/grass/wiki/Submitting/Python#Messages</a><br>
               <br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">
              <div>Perhaps the most important thing is that one should
                avoid mixing the two, which is something that maybe
                could go somewhere in the wiki?<br>
              </div>
            </blockquote>
            <div><br>
              Feel free to extent either wiki or guidelines if you think
              it is not clear enough.<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    I wouldn't mind doing so, but I probably should understand better
    myself what exactly the issue is with using both print() and
    grass.info() in one script. Based on what I read in the guidelines,
    I am not clear whether using both is against the guidelines as such,
    but technically it seems it can cause problems as you explained (and
    I experienced). <br>
    <br>
    <blockquote
cite="mid:CABo5uVtFaC_+3GWKgL+SyatRMvpAWL7KMriv_6_DrRAzNPumSg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> In my script (r.vif), both approaches have an issue
              with how output is displayed. Using <a
                moz-do-not-send="true" href="http://grass.info"
                target="_blank">grass.info</a>() results in columns not
              being printed with fixed width in the command output,
              while they are in the console. On the other hand, when
              using print() empty lines are not printed. I personally am
              not too much bothered by both, so if you think I should
              use <a moz-do-not-send="true" href="http://grass.info"
                target="_blank">grass.info</a>() I am fine with that. </div>
          </div>
          <br>
        </div>
        <div class="gmail_extra">First, always use the above guidelines
          to decide if print() or one of the g.message wrappers is the
          right solution. Second, look at the behavior in the command
          line (that's the canonical one). The GUI might get things
          wrong (and that might be bug).<br>
        </div>
      </div>
    </blockquote>
    <br>
    OK, that is good to know<br>
    <blockquote
cite="mid:CABo5uVtFaC_+3GWKgL+SyatRMvpAWL7KMriv_6_DrRAzNPumSg@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra"><br>
        </div>
        <div class="gmail_extra">Please, let me know what you think
          about it now,<br>
        </div>
        <div class="gmail_extra">Vaclav<br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>