[GRASS-dev] error in pygrass doc

Pietro peter.zamb at gmail.com
Fri Jan 8 08:21:30 PST 2016


Hi Luca,


On Fri, Jan 8, 2016 at 10:18 AM, Luca Delucchi <lucadeluge at gmail.com> wrote:
>>>> for irow in xrange(elev.rows):
> ...        new[irow] = elev[irow] < 144
> ...
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'RasterSegment' object has no attribute 'rows'

Thanks to discover this bad documentation page.

instead of elev.rows it is possible to use len(elev) to get the number
of rows, and insetad usig a variable to get the row number use just:

{{{
for irow, row in enumerate(elev):
    new[irow] = row < 144
}}}

> maybe there is a better solution, otherwise I can replace the wrong
> code in the doc with this solution.

please replace the example with enumerate.

All the best

Pietro


More information about the grass-dev mailing list