FeResPost Web Site                     FeResPost Online User Manual

V.0.2.3 Iterators

It is not possible to define several iterators in a given class in Python. Therefore, several special “Iterator” classes have been created in Python library. They are returned by the different FeResPost classes as is done for the COM component.

Let us illustrate it by an example... Consider the “each_ply” iterator defined in ClaLam class of FeResPost ruby extension. With the ruby extension, the iteration on the plies of a laminate may be performed as follows:

    ...  
    lam.each_ply do |plyDescr|  
        ...  
    end  
    ...

With Python, the code becomes:

    ...  
    for ply in lam.iter_ply():  
        ...  
    ...

One could also write:

    ...  
    x=lam.iter_ply()  
    for ply in x:  
        ...  
    ...

As in the FeResPost ruby extension, each iterator method name starts with “each_”, correspondingly, the Python methods returning an Iterator object have a name that starts with “iter_”. The correspondence between ruby extension methods and COM component methods is obvious: “each_ply” becomes “iter_ply”, “each_material” becomes “iter_material”,...