[Tutor] Lists with just an item
Negroup -
negroup at gmail.com
Mon Nov 21 11:34:35 CET 2005
2005/11/21, Alan Gauld <alan.gauld at freenet.co.uk>:
> > Each dictionary has just one key and the corresponding
> > value.
> >
> > structure = [{'field1': lenght1}, {'field2': lenght2}, ........]
>
> I'd use a tuple rather than a dictionary here:
Of course, this makes a lot of sense.
[cut]
> you can now do
>
> for field_name, displacement in structure:
> # work with values here
>
> Is that any better?
Yes, it is exactly what I was looking for!
Probably due to the lacking of experience, but each time I code a
datastructure I am never satisfied, and I have the feeling that I'm
not on the right way..
Thanks a lot for your opinion.
More information about the Tutor
mailing list