[PyQt] Sip iterator question
Sébastien Petitdemange
sebastien.petitdemange at esrf.fr
Wed Aug 19 16:16:27 BST 2009
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
-------------- 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/20090819/80beb78d/sebastien_petitdemange.vcf
More information about the PyQt
mailing list