[GRASS-dev] grass.info versus print

Vaclav Petras wenzeslaus at gmail.com
Mon Apr 11 08:18:20 PDT 2016


Hi, Paulo!

On Mon, Apr 11, 2016 at 10:04 AM, Paulo van Breugel <p.vanbreugel at gmail.com>
wrote:

> I want to provide the output formatted in three columns. I can use
>
> nlength = 20
> RES = [MAPy, vif, sqrtvif]
> print '{0[0]:{1}s} {0[1]:8.2f} {0[2]:8.2f}'.format(RES, nlength)
>
> This prints nicely on the command line. However, on the command output tab
> of the GUI, the order of the printed lines is messed up.
>

Mixing of order can happen in GUI when using both stderr and stdout. What
exactly is messed up? A minimal working example is probably needed here.


>
> If I use instead:
>
> nlength = 20
> RES = [MAPy, vif, sqrtvif]
> grass.info('{0[0]:{1}s} {0[1]:8.2f} {0[2]:8.2f}'.format(RES, nlength))
>
> It looks good on the command output tab, but it is printed without the
> fixed width.



sys.stdout/print is the way. grass.script.info and others are for messages,
not output, and they go to stderr which might cause mixing of order with
stdout in GUI and I unfortunately don't know how to avoid it.

Vaclav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20160411/56740004/attachment.html>


More information about the grass-dev mailing list