Chapter 14.4.1. Making an Iterator
Here is a simple example that lets you iterate over the parameters in a query string:
Let’s take a look at this in use:
>>> qs = new queryObj("name=Hosty%20Most&city=South%20Barton"); [object Object] >>> i = iter(qs) [object Object] >>> i.next() ["name", "Hosty Most"] >>> i.next() ["city", "South Barton"]
This is similar to how you define and use iterators in Python.
Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.