Ok now I get it. Thank you.

Le mardi 1 septembre 2015 10:29:45 UTC+2, xmarx a écrit :
>
> This is a shortcut that allows you to pass multiple arguments to a 
> function directly list. source: 
> http://stackoverflow.com/questions/36901/what-does-double-star-and-star-do-for-python-parameters
>
>
> TABLE(*[TR(*rows) for rows in table])
>
>
> TABLE
> is a function that can takes list argument. 
>
> [TR(*rows) for rows in table] 
> is a list.
>
>
>
>  
>
> 31 Ağustos 2015 Pazartesi 23:33:23 UTC+3 tarihinde Mamisoa Andriantafika 
> yazdı:
>>
>> Thank you for your highlight. You helped me to better understand the 
>> iteration.
>>
>> My main misunderstanding was actually the "*" before the "[(TR" ?
>>
>> Le lundi 31 août 2015 01:07:47 UTC+2, Anthony a écrit :
>>>
>>> [TR(*rows) for rows in table] is a list comprehension -- it iterates 
>>> over the items in "table" (which are themselves lists) and creates a new 
>>> list of TR objects.
>>>
>>> The "*" before the list is Python syntax for argument unpacking, 
>>> treating each item in the list as if it were a separate positional argument.
>>>
>>> Note, technically argument unpacking is not necessary for TABLE nor for 
>>> TR, as both will alternatively accept a list as the first argument. So, the 
>>> code could be changed to:
>>>
>>> TABLE([TR(row) for row in table])
>>>
>>>
>>> Anthony
>>>
>>> On Sunday, August 30, 2015 at 1:20:38 PM UTC-4, Mamisoa Andriantafika 
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> Could you explain to me how this code works?
>>>>
>>>> http://web2py.com/books/default/chapter/29/05/the-views#TABLE--TR--TD
>>>>
>>>> >>> table = [['a', 'b'], ['c', 'd']]
>>>> >>> print TABLE(*[TR(*rows) for rows in table])
>>>> <table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>
>>>>
>>>>
>>>> I do not completely understand how the loop is created there?
>>>>
>>>> Thank you for your highlight.
>>>>
>>>> Mike
>>>>
>>>

-- 
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