It is not. If you define multiple loop variables, Python will unpack
every item in the sequence into those variables -- so this code
for a, b in [...]:
...
is equivalent to
for item in [...]:
a, b = item
...
or
for item in [...]:
a = item[0]
b = item[0]
...
So what happens if your sequence is [{'foo': 1, 'bar': 2}]? The dict
gets unpacked into the loop variables:
for item in [{'foo': 1, 'bar': 2}]:
a, b = item
And what happens if you loop over a dict? You get a sequence of keys.
That's why in the OPs output, those keys will show up in the output.
@Schmidtchen: Use mlist.append([n+1, month, entry, current]) instead of
a dict and you're done -- that also solves the ordering issue.
And Bruno, Schmidtchen's code might really need some cleanup but that's
beyond the scope of this thread: You might have noticed that your
comments did *not help* the OP fixing his issues *at all*.
Thank you very much!! I know my code needs to be tidied up xD. I'vd tried many things to solve the problem that's why my code looks so awful. And I'm glad there is an easy solution for my problem (and I didn't saw it *wall*)
And @bruno desthuilliers: It's good for a newbie like me to see how others would solve the problem. I will look if there is something I can do better.
Django has such a grea community. Thanks to everyone!
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group. To post to this group, send email to
> django...@googlegroups.com. To unsubscribe from this group, send
> email to django-users...@googlegroups.com. For more options,
> visit this group at http://groups.google.com/group/django-users?hl=en.
>