[PyKDE] Iterators / generators for QList(Box, View) and other?

Torsten Marek shlomme at gmx.net
Wed Apr 2 16:41:00 BST 2003


Hello there,

I just wanted to ask if some version of PyQt will support iterators for 
Listboxes, Listviews etc. through generator functions or the __iter__ 
protocol? I know both are Python 2.2+ specific, but are there any plans 
to implement them, Phil? Is anybody of you interested in having them? A 
simple iterator for a QListBox using generators would look like this 
(works only with Python 2.2 or greater):



from __future__ import generators 	# python2.2 only

def ListBoxIterator(listbox):
	item = listbox.firstItem()
	while item:
		yield item
		item = item.next()
	return 				# no special need to do this

Don't know about generators yet? Read 
http://www.python.org/doc/2.3a2/whatsnew/section-generators.html
to get a fast intro.

Greetings,

Torsten
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 252 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20030402/93199993/attachment.bin


More information about the PyQt mailing list