Friday, July 30, 2010

Re: Best way to present N items in table row for list

On 29 июл, 12:08, Roald de Vries <downa...@gmail.com> wrote:

> First: list is a very unlucky name for a parameter, since it's the  
> type of []
>
> Second: list comprehension rules!
>
>      def groupListByRow(list):
>          return [lst[start:start+5] for start in range(0, len(lst), 5)]
>
> Cheers, Roald

Perfect!!!! This is why people use Python!!!! Simple, short, elegant

Finally i will use Roald's solution. The transformation in template
is possible, but not so clear.
Thanks to all for their help.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment