An example of an iterator with Python library is in “PYTHON/EX02/printGroups.py” and reads as follows:
for groupName in db.iter_groupName(): grp = db.getGroupCopy(groupName) nodesNbr = grp.NbrElements elementsNbr = grp.NbrNodes rbesNbr = grp.NbrRbes coordNbr = grp.NbrCoordSys print("%20s%10d%10d%10d%10d"%(groupName,nodesNbr,elementsNbr, rbesNbr,coordNbr))
Note:
The parentheses at the end of “iter_groupName” method call. (This is specific to the Python language.)
The “:” that defines the beginning of the instructionqs bloc in Python. This is also specific to Python language, as is the fact that the indentation of the code defines the limits of instruction blocs.
And of course, the fact that ruby “each_groupName” iteration method is replaced by a call to the Python “iter_groupName” function that returns an iterable object.