← Back to team overview

dolfin team mailing list archive

Re: itercell and consistency in Python interface of DOLFIN

 

On Fri, Jan 21, 2011 at 05:49:08AM -0800, Johan Hake wrote:
> On Friday January 21 2011 01:16:24 Anders Logg wrote:
> > B1;2600;0cOn Thu, Jan 20, 2011 at 04:13:19PM -0800, Johan Hake wrote:
> > > Hello!
> > >
> > > For awhile I have wanted to change the naming of cells, vertices, aso to
> > > itercells, itervertices, as it would be more Pythonic.
> >
> > Is 'iterfoo' common in Python? I haven't seen it before. So to me
> >
> >   for cell in cells(mesh):
> >       ...
> >
> > still looks very neat.
>
> Compare the values and itervalues method in a dict. I would expect cell(mesh)
> to return a list of cells or somthing.
>
> Maybe we can add:
>
>   mesh.itercells, mesh.iterentity(2), aso
>
> then we are talking pythonic. We could keep cells, vertices aso, for
> compatability.

Sounds good.

--
Anders


> > The C++ iterators are also don't follow the regular C++ style but I
> > think
> >
> >   for (CellIterator cell(mesh); !cell.end(); ++cell)
> >
> > looks better than
> >
> >   for (<something>::iterator cell = mesh.<something>.begin(); cell !=
> > mesh.<something>.end(); ++cell)
> >
> > so we're not necessarily following the standard convention always if
> > we think we can do better.
>
> sure. But it has turned out that Python is a pretty good standard. :)
>
> > > I also wonder if we should change the naming of
> > >
> > >   MeshFunction.values
> > >
> > > to
> > >
> > >   MeshFunction.array.
> >
> > That sounds good.
>
> Ok will do change.
>
> Johan
>
>
>



References