On Wednesday, May 7, 2014 9:31:29 AM UTC-4, Diogo Munaro wrote:
>
> Hi Anthony, thx for your help, I was using table inside lambda then table 
> value was always the last table.
>

If you are iterating over some items to create lambdas, you must pass each 
item to the lambda as an argument with a default value -- otherwise, all 
lambdas get the last value of the iteration (because the items are defined 
in the scope outside of the lambda). So, instead of:

for t in tables:
    mycallbacks.append(lambda: do_something_with(t))

it should be:

for t in tables:
    mycallbacks.append(lambda table=t: do_something_with(table))

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to