[PyQt] Sip iterator question
Sébastien Petitdemange
sebastien.petitdemange at esrf.fr
Mon Aug 24 12:08:44 BST 2009
No one could help?
SEB
Sébastien Petitdemange wrote:
> Hello All,
>
> I try to create an iterator using python iterator protocol but I didn't
> succeed.
>
> The sip code look like that:
>
> struct Data_HeaderContainer_itemIterator
> {
> %TypeHeaderCode
> #include "data_header_iterator.h"
> %End
>
> public:
> Data_HeaderContainer_itemIterator(Data::HeaderContainer&);
> SIP_PYOBJECT next();
> %MethodCode
> if(sipCpp->_cur != sipCpp->_end)
> {
> sipRes =
> Py_BuildValue("(ss)",sipCpp->_cur->first.c_str(),sipCpp->_cur->second.c_str());
> ++(sipCpp->_cur);
> }
> else
> PyErr_SetString(PyExc_StopIteration,"");
> %End
>
> 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?
>
> Thanks in advance,
> SEB
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sebastien_petitdemange.vcf
Type: text/x-vcard
Size: 210 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090824/e55882c6/sebastien_petitdemange.vcf
More information about the PyQt
mailing list