[redland] Iterator support for Python API

Dave Beckett dave.beckett at bristol.ac.uk
Wed Aug 7 17:41:09 BST 2002


>>>Andrew Kuchling said:
> Would a patch to add iterator support for Iterator and Stream be
> accepted?  This would simplify looping a bit, so instead of:

You mean python generators, not iterators?

> while not stream.end() :
>   model.add_statement(stream.next())
> 
> you could write:
> 
> for statement in stream:
>   model.add_statement(statement)

Yes, that's dooable.

Edd Dumbill has been making a lot of changes and improvements to the
redland Python API after the 0.9.11 release - he can probably
comment.  We were considering adding generators but that raises the
python minimum version as you say:

> Iterators are only in Python 2.2, so Python 2.1 support would be lost,
> and it'll change the API of the Iterator and Stream classes.  If this
> is considered worthwhile, I can provide a patch.

The API changes I don't mind, this stuff is still in flux.

> Incidentally, pychecker reports the following warnings for the last
> released version of RDF.py.  The ones at line 159 and 174 look like
> actual bugs (should be _set_type(value) and librdf_new_uri_from_uri,
> perhaps?).
> 
> r2.py:36: Imported module (sys) not used
> r2.py:37: Imported module (string) not used
> r2.py:68: Parameter (digest_name) not used
> r2.py:68: Parameter (uri_hash) not used
> r2.py:159: Invalid arguments to (_set_type), got 0, expected 1
> r2.py:174: No module attribute (librdf_uri_from_uri) found

That stuff may have changed in the latest snapshots.

Try it from 
  http://www.redland.opensource.ac.uk/dist/snapshots/source/redland-0.9.12.tar.gz

but I can't guarantee that it'll build at the moment, since I'm
adding new things and reworking some internals.

Dave







More information about the redland-dev mailing list