Sounds good.  Modify at will!

On Oct 28, 12:26 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
> Very much!
> I propose one change. Just one API (filter) and an extra parameter
> (inplace=True|False).
> What you think?
>
> On Oct 28, 12:11 am, "mr.freeze" <nat...@freezable.com> wrote:
>
> > Works! Would you be interested in these for sql.py Rows class?:
>
> > def where(self,f):
> >     if not self.response:
> >         return None
> >     rows = []
> >     for i in range(0,len(self)):
> >         row = self[i]
> >         if f(row): rows.append(self.response[i])
> >     return Rows(self._db,rows,*self.colnames)
>
> > def filter(self,f):
> >     if not self.response:
> >         return None
> >     rows = self.response
> >     removed = []
> >     for i in range(0,len(self)):
> >         row = self[i]
> >         if f(row):
> >             removed.append(rows[i])
> >             rows.remove(rows[i])
> >     return Rows(self._db,removed,*self.colnames)
>
> > Example:
> > db.define_table('things',Field('category'))
> > rows = db(db.things.id>0).select()
> > tests = rows.where(lamdba row: row.category=="test") # returns matches
> > rows.filter(lamdba row: row.category=="test")# removes and returns
> > removed
>
> > On Oct 27, 10:49 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > Thanks. Just fixed in trunk!
>
> > > On Oct 27, 10:35 pm, "mr.freeze" <nat...@freezable.com> wrote:
>
> > > > I get a syntax error when using this. I believe line 2926 of
> > > > Rows.__getitem__ needs to be changed from:
>
> > > > if i >= len(self.response) or i < 0:
>
> > > > ...to...
>
> > > > if i >= len(self.response):
>
> > > > since Rows.last() returns self[-1]
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to