Sunday, June 1, 2014

Re: Transform list comprehension back to traditional looping construct, how?

Thank you Hannu and François, now I understand!  I've been searching for almost 4 months to solve this one in my Django project.  :D





On Sun, Jun 1, 2014 at 5:03 PM, Hannu Krosing <hannu@krosing.net> wrote:
On 06/01/2014 03:00 PM, Pepsodent Cola wrote:
At first I was trying to use list.append but then Python complained that append could only take 1 argument.  So I google around and list.extend said that it could take more arguments so I just went with it.

What is this right method you are thinking about? 
list.append(<tuple>)

instead of

list.append(individual, tuple, elements)

My imagination is very limited I only know of append but not sure how to work with it in this situation.



On Sunday, June 1, 2014 2:52:33 PM UTC+2, Masklinn wrote:

On 2014-06-01, at 14:29 , Pepsodent Cola <pepsod...@gmail.com> wrote:

> Hi, I want to transform my articles_list5 list comprehension back to a traditional looping construct to make things easier to read.
> The articles_list5 returns a list of tuples.
>
> But when I try to do the same using traditional looping in articles_list6 then I just get one long list from everything.  How do I transform list5 to list6 correctly so it still returns a list of tuples?

By using the right method? Why are you calling list.extend?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/UxYLlh_Wce8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/538B40B2.90907%40krosing.net.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOWMwCztLKLhh66qMbhtSpf1n20q__GEVfMt%3DKdRKKX5yum6Fg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment