Hi Mart,

following your example I am not sure what you want but try something
like

rows = db(db.animal.paws==4).select()
last_rows = [rows.find(lambda r: r.species=x).last() for x in myList]



On Apr 15, 4:51 am, mart <[email protected]> wrote:
> Hi,
>
> Is there a way to pass a list to rows = db(...).select().last() ?
>
> would be a time saver to be able to do something like:
>
>         myList = ['dog,
>                       'cat,
>                       'kangooroo',
>                       'fish']
>
>         4_legged_pets = []
>
>         rows = db((db.animal.id>0)&(db.animal.paws==4)).select()
>         last_rows = rows.last(myList)
>         for pet in last_rows:
>             if pet['paws'] == 4:  4_legged_pets.append(pet)
>             elif pet['paws'] == 2:  ...blablabla
>
> this way we get the last_row for all animals in one call (saves tones
> of typing time)
>
> is there a built-in way for doing this or is it best to make a
> function somewhere? Of course checking  if db.animal.isempty(): before
> would also be a time saver :)
>
> thanks,
> Mart :)

Reply via email to