iterator support (in ext. module)
jarausch at igpm.rwth-aachen.de
Mon Jun 28 11:00:32 CEST 2004
sorry for the questions but I'm not sure I understand the
In an own extension module I have a new type called Hitlist,
which has the methods 'first', 'last', 'next' and 'previous'.
Now I'd like to support iterating on this type, e.g. like
for Rcd in HL:
for Rcd in HL.reverse() :
What do I need to implement to get that functionality?
Unfortunately the chapter 10.8 'Supporting the Iterator Protocol' of the
(devel) docu seems to be empty.
What should PyTypeObject.tp_iter be set to? Can I just return 'self'
and is PyTypeObject.tp_iternext an alias for my 'next' method?
Does a call to 'PyTypeObject.tp_iter' reset the iterator s.t.
'tp_iternext' returns the first object when called afterwards?
Many thanks for your help,
(P.S. I'm using Version 2.4 -cvs)
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
More information about the Python-list