"for .. in" uses __getitem__, which must raise IndexError to stop the
iteration.
Nick
On Tue, 2003-05-20 at 11:12, Bud P.Bruegger wrote:
> Sorry, I wasn't clear. I need something for the iteration ('in' and
> 'for'). I have since read up a litte and it seems I need __iter__
> (see http://www.python.org/doc/current/ref/sequence-types.html).
>
> What kind of surprises me is that the built in lists (as in type([]))
> don't have an __iter__ method but are a prime example for supporting
> the "in" loop... Maybe a leftover of older python versions...
>
> --b
>
> On 20 May 2003 10:43:58 -0500
> Nick <ni...@dd...> wrote:
>
> > I assumed wrong. Looks like __getitem__ is what you want.
> >
> > Nick
> >
> > On Tue, 2003-05-20 at 07:04, Bud P.Bruegger wrote:
> > > and as a followup:
> > >
> > > Of particular magic to me is what happends here:
> > >
> > > for item in myList:
> > > print item
> > >
> > > I frankly haven't a clue what secial method to override to get control
> > > over what is returned as items...
> > >
> > > any idea?
> > >
> > > /-----------------------------------------------------------------
> > > | Bud P. Bruegger, Ph.D.
> > > | Sistema (www.sistema.it)
> > > | Via U. Bassi, 54
> > > | 58100 Grosseto, Italy
> > > | +39-0564-411682 (voice and fax)
> > > \-----------------------------------------------------------------
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.net email is sponsored by: ObjectStore.
> > > If flattening out C++ or Java code to make your application fit in a
> > > relational database is painful, don't do it! Check out ObjectStore.
> > > Now part of Progress Software. http://www.objectstore.net/sourceforge
> > > _______________________________________________
> > > sqlobject-discuss mailing list
> > > sql...@li...
> > > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: ObjectStore.
> > If flattening out C++ or Java code to make your application fit in a
> > relational database is painful, don't do it! Check out ObjectStore.
> > Now part of Progress Software. http://www.objectstore.net/sourceforge
> > _______________________________________________
> > sqlobject-discuss mailing list
> > sql...@li...
> > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
> >
>
>
> /-----------------------------------------------------------------
> | Bud P. Bruegger, Ph.D.
> | Sistema (www.sistema.it)
> | Via U. Bassi, 54
> | 58100 Grosseto, Italy
> | +39-0564-411682 (voice and fax)
> \-----------------------------------------------------------------
|