No no. Exclude is designed to remove the rows from the original rows
object. It returns the exluded rows.
Yes it does return the same as find but the way they act on the
original rows are different.
It does what it is designed to do.

Yours does something else.

On Nov 29, 2:55 am, Thadeus Burgess <thade...@thadeusb.com> wrote:
> Ok, I'm not sure why exclude is written completely different than find...
> but it returns the exact same results :)
>
> Given
> Rows =
> id name
> 1 hello
> 2 hello
> 3 hi
> 4 good morning
>
> list = Rows.find(lambda row: row.name == 'hello')
> YIELDS
> 1, 2
>
> list = Rows.exclude(lambda row: row.name == 'hello')
> SHOULD YIELD
> 3, 4
> BUT ACTUALLY YIELDS
> 1, 2
>
> Here is a correct, working version of exclude
>
> def exclude(self,f):
>         """
>         returns a set of rows of sorted elements (not filtered in place)
>         """
>         if not self.records:
>             return []
>         records = []
>         for i in range(0,len(self)):
>             row = self[i]
>             if not f(row):
>                 records.append(self.records[i])
>         return Rows(self.db,records,self.colnames)
>
> -Thadeus

--

You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@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