[PyQt] Sip iterator question

David Boddie david at boddie.org.uk
Wed Aug 26 00:50:33 BST 2009


On Mon, 24 Aug 2009 13:08:44 +0200, Sebastien Petitdemange wrote:

> Sébastien Petitdemange wrote:

> > I try to create an iterator using python iterator protocol but I didn't
> > succeed.

[...]

> > Data_HeaderContainer_itemIterator* __iter__();
> > %MethodCode
> > sipRes = sipCpp;
> > %End
> > };
> >
> > and we I use it in python, It say that my object is not an iterator :
> >
> > for k in i:
> > ...     print k
> > ...
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > TypeError: 'Data_HeaderContainer_itemIterator' object is not iterable
> >
> > what I'm I missing?

Maybe the value returned by __iter__() isn't what the interpreter is
expecting. Having said that, I think it's possible that the type structure
information created by SIP doesn't have the necessary fields filled in to
allow the object to be used to create an iterator, even if you define
__iter__() for this purpose.

Has anyone else encountered this problem, perhaps with tools other than SIP?

David



More information about the PyQt mailing list